springboot项目有多个模块,在项目编译时报如下错误:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEASE:repackage (repackage) on project xxx: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEASE:repackage failed: Unable to find a single main class from the following candidates [xxx.xxxx.Class] -> [Help 1]
[ERROR]
原因是项目的根pom.xml中配置了build:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<!-- 指定resources插件处理哪个目录下的资源文件 -->
<directory>src/main/resources</directory>
<!-- 打开资源过滤功能 -->
<filtering>true</filtering>
</resource>
</resources>
</build>
而项目中,不是所有的模块都是可以打包成可运行的JAR包,故引发了报错。
解决方案是,在编译报错的模块pom.xml中配置build:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
再次编译则可顺利完成编译。
网友评论