前置条件
jdk 1.8
spring-boot-maven-plugin 未指定版本
<spring-boot.version>2.6.4</spring-boot.version>
报错信息
使用若依的开源框架在打包时,发现突然出现了打包失败的情况。
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
报错信息提示,插件不兼容。
后续经过查找,最新发布的3.0.0版本,在2022年11月24号发布了。
spring-boot-maven-plugin 的版本号最新版本基于 JDK17 编译的 3.0 版本
原因
因为使用了JDK1.8,然后版本也是未指定。导致打包时拉取最新版本3.0.0版本,出现插件不兼容导致打包失败。
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
修改成基于 springboot版本号, <spring-boot.version>2.6.4</spring-boot.version>,不会超过3.0.0
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
报错解决