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

在接手的老项目中,由于服务器重启后尝试重新部署Jenkins服务时遇到错误,具体是由于spring-boot-maven-plugin没有指定版本,导致与JavaRuntime版本不兼容。错误信息提到类文件版本不匹配。解决方案是将spring-boot-maven-plugin版本指定为之前成功部署的日志中的2.2.5.RELEASE,通过修改配置文件并添加version标签,问题得到解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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>

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值