前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SpringBoot启动报错Unable to find a suitable main class

SpringBoot启动报错Unable to find a suitable main class

作者头像
零云
发布2023-07-24 21:31:02
1.1K0
发布2023-07-24 21:31:02
举报

在启动一个spring-boot多模块项目时始终报错:Unable to find a suitable main class, please add a 'mainClass' property

试了如增加mainClass配置无效,最终定位是因为父pom里面存在:

代码语言:javascript
复制
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.1.RELEASE</version>
</parent>

而spring-boot-starter-parent中包含spring-boot-maven-plugin,而父模块并没有主类入口所以需要跳过:

代码语言:javascript
复制
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <skip>true</skip>
    </configuration>
</plugin>

需要注意的是子模块如果有引入spring-boot-maven-plugin,需要将skip设置为false,否则会出现全部模块编译成功,但是没有服务启动的情况。

代码语言:javascript
复制
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <skip>false</skip>
    </configuration>
</plugin>
本文参与?腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2023-01-10 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客?前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体分享计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com