【发布时间】:2022-02-05 21:54:52
【问题描述】:
运行 maven 包目标时
mvn 清洁包
构建抛出错误:
目标 org.springframework.boot:spring-boot-maven-plugin:3.0.0-M1:repackage failed: 无法在插件 'org.springframework.boot:spring-boot-maven 中加载 mojo 'repackage' -plugin: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>
【问题讨论】:
-
您似乎尝试使用需要JDK17的spring boot 3.0.0-M1版本...您无法编译也无法与JDK8一起使用。
-
听起来好像 spring-boot-maven-plugin 没有选择与 spring-boot-starter 相同的版本。我已将我的开始定义为 spring-boot 依赖管理的一部分。
-
问题是你为什么要配置 maven-war-plugin ?我想你的问题是你没有使用spring boot parent?或者您正在使用 spring-boot-dependencies 作为 BOM,这也可能是一个问题。另外,您为什么要更改默认目录?真的没有意义
-
#Spring-boot-parent:作为依赖管理的一部分添加到我的父模块中。此外,我必须使用自定义父级#maven-war-plugin:我将应用程序打包为战争。
-
#maven-war-plugin:我已经摆脱了自定义包装,假设它在重新包装时可能会导致问题。所以我认为默认目录不应该受到影响。
标签: java spring-boot maven spring-boot-maven-plugin maven-package