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

  • 阿里云国际版折扣https://www.yundadi.com

  • 阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
    本篇内容主要讲解“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包

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

    • 阿里云国际版折扣https://www.yundadi.com

    • 阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
      标签: Spring

      “spring-boot-maven-plugin未指定版本导致的编译错误问题怎么解决 - 开发技术” 的相关文章

      php.ini详细错误指的是什么 - 编程语言

      这篇文章主要讲解了“php.ini详细错误指的是什么”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“php.ini详细错误指的是什么”吧! PHP ini详细错误是一种配置错误,通常会在服务器...

      CompletableFuture怎么使用 - 开发技术

      这篇文章主要讲解了“CompletableFuture怎么使用”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“CompletableFuture怎么使用”吧!一个美好的期望通常情况下,我们希望代码的执行顺序和代码的组织顺...

      Python网络爬虫之Web网页基础是什么 - 开发技术

      本文小编为大家详细介绍“Python网络爬虫之Web网页基础是什么”,内容详细,步骤清晰,细节处理妥当,希望这篇“Python网络爬虫之Web网页基础是什么”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。1.网页的组成网页主要是三大部分组成&...

      WebSocket实现后端数据变化,通知前端实时更新数据

      背景 ​ 项目中需要做一个消息提示功能当有用户处理相关待办信息后别的用户需要实时更新处理后的待办信息。 解决方案 ​ 1、使用最原始的方法写个定时器去查询待办信息。但这种方式在大多数情况是不被允许的它会浪费系统中的许多资源同时也并不是完全意义上的实时更新。 ​ 2、使用WebSocket通信...

      UVa 10730 Antiarithmetic? (想法题)

      10730 - Antiarithmetic?Time limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1671A permu...

      工作中ibatis中的连表查询及in()的使用案例

      public class CbExchangeOrderArr extends BaseBean implements Serializable { /** * */ private static final long serialVersio...