0

运行 Maven 包目标时

mvn 清洁包

构建抛出错误:

目标 org.springframework.boot:spring-boot-maven-plugin:3.0.0-M1:repackage failed: 无法在插件 '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>
4

1 回答 1

1

pom.xml 中使用的“spring-boot-maven-plugin”插件版本是 3.0.0-M1,只能与 Java 17 或更高版本一起使用。切换到 2.5.7,如果它真的是你想用于 spring boot 项目的版本。

于 2022-02-06T07:08:08.683 回答