当前位置:   article > 正文

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

unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:

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部署的时候自动获取最新版本,而最新版本的不兼容,导致的该问题,以下代码是历史代码:

  1. <plugin>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-maven-plugin</artifactId>
  4. <configuration>
  5. <mainClass>com.XXXX.XXXX</mainClass>
  6. <fork>true</fork>
  7. <addResources>true</addResources>
  8. </configuration>
  9. <executions>
  10. <execution>
  11. <goals>
  12. <goal>repackage</goal>
  13. </goals>
  14. </execution>
  15. </executions>
  16. </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>

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/522505
推荐阅读
相关标签
  

闽ICP备14008679号