【背景】
spring-boot项目执行mvn clean package
打包时遇到一个问题,报错如下:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.4.RELEASE:repackage (default) on
project behavior-data: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.3.4.RELEASE:repackage failed:
Unable to find a single main class from the following candidates [com.xxx.client.BehaviorDataApplication, com.xxx.client.domain.ReportRankDataDomain]
BehaviorDataApplication和ReportRankDataDomain类都有自己的main方法,BehaviorDataApplication是主启动类。看提示明显和spring-boot-maven-plugin插件打包有关系。
【解决】
这里其实就是spring-boot-maven-plugin插件在repackage时,会去寻找签名为public static void main(String[] args)
的方法,但项目中有多个,所以插件懵逼了,不知道该找哪个。
直接说解决方式
在插件配置里手动配置下mainClass,指定程序入口。
<plugin>
<groupId