spring-boot-maven-plugin未指定版本导致的编译错误问题怎么解决

发布时间:2023-04-11 16:50:06 作者:iii
来源:亿速云 阅读:187

本篇内容主要讲解“spring-boot-maven-plugin未指定版本导致的编译错误问题怎么解决”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“spring-boot-maven-plugin未指定版本导致的编译错误问题怎么解决”吧!

spring-boot-maven-plugin未指定版本导致的编译错误

报错

springboot应用在使用maven编译时会报如下错误:

Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-M2:repackage (default) on project mis: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-M2:repackage failed: Unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:spring-boot-maven-plugin:3.0.0-M2' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/springframework/boot/maven/RepackageMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Caused by: java.lang.UnsupportedClassVersionError: org/springframework/boot/maven/RepackageMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

原因

原因是maven在编译打包过程中没有指定spring-boot-maven-plugin的版本,默认会从nexus仓库中拉取最新的打包插件版本,而最新的3.0.0版本不被jdk8支持,无法执行编译。

解决方案

需要用户在pom.xml文件中手动指定spring-boot-maven-plugin该插件的打包版本。

如:

加上版本<version>2.2.6.RELEASE</version>

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.2.6.RELEASE</version>
                <configuration>
                    <finalName>${project.artifactId}</finalName>
                    <mainClass>com.xxl.job.admin.XxlJobAdminApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

spring-boot-maven-plugin 构建找不到

问题描述

本地编译打包maven项目时,报spring-boot-maven-plugin 构建找不到的错误。昨天还好好的,本地代码里的pom文件没有做任何改动。

pom.xml中有一段下面的配置:(已去掉项目信息)

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <classifier>boot</classifier>
        <mainClass>...</mainClass>
    </configuration>
</plugin>

关键错误信息如下:

spring-boot-maven-plugin-2.3.1.RELEASE.jar找不到。

分析

通过对比,发现远程仓库里有了最新版本的路径,但是里面确没有jar包。

解决

通过分析,可以总结如下:

spring-boot-maven-plugin没有设置version,它会先去远程仓库找最新的版本,然后download到本地,然后完成maven操作等。但是远程仓库里没有相应的jar包,导致执行maven编译出错。因为远程仓库里已经有了最新版本的路径,它就不会使用已经存在的版本。

解决:

给spring-boot-maven-plugin指定具体的version,如下设置:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <version>2.3.0.RELEASE</version>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <classifier>boot</classifier>
        <mainClass>...</mainClass>
    </configuration>
</plugin>

到此,相信大家对“spring-boot-maven-plugin未指定版本导致的编译错误问题怎么解决”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

推荐阅读:
  1. PHP中加密解密类的示例分析
  2. 怎么在php中通过分类列表生成一个分类树数组

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

spring-boot-maven-plugin

上一篇:python免杀技术shellcode的加载与执行方法是什么

下一篇:Python中的迭代器怎么创建

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》