springboot項(xiàng)目有多個(gè)模塊,在項(xiàng)目編譯時(shí)報(bào)如下錯(cuò)誤:
[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]
原因是項(xiàng)目的根pom.xml中配置了build:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<!-- 指定resources插件處理哪個(gè)目錄下的資源文件 -->
<directory>src/main/resources</directory>
<!-- 打開資源過(guò)濾功能 -->
<filtering>true</filtering>
</resource>
</resources>
</build>
而項(xiàng)目中,不是所有的模塊都是可以打包成可運(yùn)行的JAR包,故引發(fā)了報(bào)錯(cuò)取试。
解決方案是,在編譯報(bào)錯(cuò)的模塊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>
再次編譯則可順利完成編譯怀吻。