广告
返回顶部
首页 > 资讯 > 后端开发 > Python >spring-boot-maven-plugin未指定版本导致的编译错误问题
  • 206
分享到

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

Python 官方文档:入门教程 => 点击学习

摘要

目录spring-boot-Maven-plugin未指定版本导致的编译错误报错原因解决方案spring-boot-maven-plugin 构建找不到问题描述分析解决总结sprin

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包
  • ${user.home}/.m2
  • 去远程仓库查看,检查是否有该版本的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>

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。

--结束END--

本文标题: spring-boot-maven-plugin未指定版本导致的编译错误问题

本文链接: https://www.lsjlt.com/news/208610.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作