Spring 使用 spring 版本 2.5.7 启动无法使用 jdk 1.8 重新打包
Spring Boot with spring version 2.5.7 fails repackage with jdk 1.8
当运行一个maven包目标
mvn clean package
构建抛出错误:
goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-M1:repackage failed: Unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:spring-boot-maven-plugin:3.0.0-M1' 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
我的JAVA_HOME指向jdk1.8.0_73
如何获得 spring-boot-maven-plugin 运行 重新打包目标?
下面是我模块中的maven构建配置。
<build>
<resources>
<resource>
<directory>resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
<webResources>
<resource>
<directory>src/main/resources</directory>
<include>*.*</include>
<targetPath>/WEB-INF/classes</targetPath>
</resource>
<resource>
<directory>src/main/webapp/errors</directory>
<include>*.*</include>
<targetPath>/errors/</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.services.MyAApp</mainClass>
<layout>war</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
您 pom.xml 使用的 'spring-boot-maven-plugin' 插件版本为 3.0.0-M1,只能与 Java 17 或更高版本一起使用。切换到 2.5.7,如果它确实是您想要用于 spring 引导项目的版本。
当运行一个maven包目标
mvn clean package
构建抛出错误:
goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-M1:repackage failed: Unable to load the mojo 'repackage' in the plugin 'org.springframework.boot:spring-boot-maven-plugin:3.0.0-M1' 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
我的JAVA_HOME指向jdk1.8.0_73
如何获得 spring-boot-maven-plugin 运行 重新打包目标?
下面是我模块中的maven构建配置。
<build>
<resources>
<resource>
<directory>resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
<webResources>
<resource>
<directory>src/main/resources</directory>
<include>*.*</include>
<targetPath>/WEB-INF/classes</targetPath>
</resource>
<resource>
<directory>src/main/webapp/errors</directory>
<include>*.*</include>
<targetPath>/errors/</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.services.MyAApp</mainClass>
<layout>war</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
您 pom.xml 使用的 'spring-boot-maven-plugin' 插件版本为 3.0.0-M1,只能与 Java 17 或更高版本一起使用。切换到 2.5.7,如果它确实是您想要用于 spring 引导项目的版本。