Unable to load the mojo ‘repackage‘ in the plugin ‘org.springframework.boot:spring-boot-maven-plug

1.最近接手了一个老项目,由于重启服务器,需要启动服务,但是发现再次部署Jenkis报错,不能重新部署报错,报错信息如下:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.5:repackage (default) on project XX-manager: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:3.0.5:repackage failed: Unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:spring-boot-maven-plugin:3.0.5' 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

ps:不涉及到Jenkis,如果是本地编译报错,也是这样解决处理。

2.原因

由于spring-boot-maven-plugin没有指定版本,Jenkis部署的时候自动获取最新版本,而最新版本的不兼容,导致的该问题,以下代码是历史代码:


                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <configuration>
                        <mainClass>com.XXXX.XXXX</mainClass>
                        <fork>true</fork>
                        <addResources>true</addResources>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

3.解决办法

spring-boot-maven-plugin指定版本,查看了Jenkis的部署成功的日志,之前成功的获取的版本是“2.2.5.RELEASE”(可以根据需要尝试低版本的),将version设置为2.2.5.RELEASE就可以了。

Jenkis部署成功的日志:
[INFO] --- spring-boot-maven-plugin:2.2.5.RELEASE:repackage (default) @ XXXX ---
[INFO] Replacing main artifact with repackaged archive

修改的配置文件:
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                      <version>2.2.5.RELEASE</version>
                    <configuration>
                        <mainClass>com.XXXX.XXXX</mainClass>
                        <fork>true</fork>
                        <addResources>true</addResources>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

这样问题就解决了,如果对您有帮助,记得点赞呀~

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当在Spring Boot项目中遇到"unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:"的错误信息时,这通常意味着在构建项目时出现了问题。 此错误通常是由以下几个常见原因引起的: 1. 插件版本不兼容:确保项目的Spring Boot插件版本与项目依赖的其他插件版本兼容。可以参考Spring Boot官方文档或Spring官方网站获取更多插件版本信息。 2. 缺失插件依赖:检查项目的pom.xml文件或构建工具配置文件,确保所有依赖的插件都已正确添加。 3. 插件配置错误:检查pom.xml文件或构建工具配置文件中的插件配置是否正确。 4. 项目构建失败:可能是由于项目构建过程中出现了其他错误,导致插件无法加载。检查项目构建日志,查找其他的错误信息。 解决此错误的方法可以尝试以下几种: 1. 更新插件版本:尝试更新Spring Boot插件版本到最新版本,确保与其他插件版本兼容。 2. 检查插件依赖:检查项目的pom.xml文件或构建工具配置文件,确保所有依赖的插件都已正确添加,并且版本正确。 3. 清除本地仓库:删除本地Maven仓库中与该插件相关的文件,并重新构建项目,以便重新下载插件。 4. 检查项目构建日志:仔细查看项目构建日志,查找其他的错误信息,修复错误后重新构建项目。 总的来说,"unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:"的错误通常是由于插件版本不兼容、缺失插件依赖、插件配置错误或项目构建失败等原因造成的。通过更新插件版本、检查插件依赖、清除本地仓库和检查项目构建日志等方法可以尝试解决此错误。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值