使用 spring 版本 2.5.7 的 Spring Boot 无法使用 jdk 1.8 重新打包

Leo*_*Leo 4 java maven spring-boot maven-package spring-boot-maven-plugin

运行 Maven 包目标时

mvn清理包

构建抛出错误:

目标 org.springframework.boot:spring-boot-maven-plugin:3.0.0-M1:repackage 失败:无法加载插件 'org.springframework.boot:spring-boot-maven-plugin 中的 mojo 'repackage': 3.0.0-M1' 由于 API 不兼容:org.codehaus.plexus.component.repository.exception.ComponentLookupException:org/springframework/boot/maven/RepackageMojo 已由更新版本的 Java 运行时(类文件版本 61.0),此版本的 Java 运行时仅识别 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>
Run Code Online (Sandbox Code Playgroud)

ruf*_*nov 13

pom.xml 中使用的“spring-boot-maven-plugin”插件版本是 3.0.0-M1,只能与 Java 17 或更高版本一起使用。如果您确实想将其用于 Spring Boot 项目,请切换到 2.5.7。