Unable to find a single main class from the following candidates [cn.CommunityApplication, cn.xxx.xxx.CommunityApplication]

后端 0 483
小小草
小小草 2023年2月26日 00:30 发表

今天maven打包工程,突然报异常了,真的好奇怪

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.6.RELEASE:repackage (repackage) on project zhishishequ: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.1.6.RELEASE:repackage failed: Unable to find a single main class from the following candidates [cn.CommunityApplication, cn.xxx.xxx.CommunityApplication] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

意思是:springboot无法找到一个主启动类

工程为:springboot的父子模块工程,common模块为基础支持模块,不需要启动类的。

那打包的时候为什么会到common模块找启动类呢。

挨个翻了下pom文件,原来在一次排查问题时,在父pom里加了个spring-boot-maven-plugin插件]

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

这就导致,打包的时候,会在各模块寻找启动类。

经验教训 

1,调试工程时,要考虑全面,仔细验证比较后再提交代码,不要解决一个问题而又引入另一个问题,给自己和他人带来麻烦

2,spring-boot-maven-plugin打包插件不要在父模块添加,哪个子模块需要,哪个再添加



点赞 0 收藏(0)    分享
相关标签: springboot maven
问题没解决?让chatGPT帮你作答 智能助手
0 个评论
  • 消灭零评论