You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot启动后提示Process finished with exit code 0问题求助

Spring Boot启动后直接退出(Process finished with exit code 0)问题排查

问题描述

  • 已查阅Stack Overflow及其他技术网站,未找到有效解决方案,尝试过部分推荐方法但无效
  • Spring Boot应用启动后立即退出,控制台显示Process finished with exit code 0
  • 已添加Web应用所需依赖,执行过Maven清理(mvn clean)、构建(mvn package)及IDE依赖刷新操作,问题仍存在
  • 相关配置:pom.xml(附截图)、控制台输出(附截图)

排查与解决步骤

1. 确认启动类配置正确性

  • 检查启动类是否添加@SpringBootApplication注解,且类所在包为项目根包(保证组件扫描范围覆盖所有业务代码)
  • 验证main方法实现是否标准,示例代码:
@SpringBootApplication
public class YourApplication {
    public static void main(String[] args) {
        SpringApplication.run(YourApplication.class, args);
    }
}

2. 验证Web依赖引入有效性

  • 检查pom.xml中是否正确引入spring-boot-starter-web依赖,示例:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
  • Spring Boot 3.x版本需配合JDK 17及以上使用,版本不兼容会导致Web容器无法启动

3. 开启详细日志定位问题

  • 在application.properties中添加日志配置,开启DEBUG级别:
logging.level.root=DEBUG
  • 重启应用后查看日志,若未出现Tomcat/Jetty/Undertow等Web容器初始化日志,说明Web服务未被触发启动

4. 检查自定义Runner逻辑

  • 若项目中实现了ApplicationRunner或CommandLineRunner接口,排查其run方法是否包含System.exit(0)或其他终止JVM的代码,如有需移除

5. 排查Maven依赖冲突

  • 执行命令mvn dependency:tree查看依赖树,排查是否存在Web相关依赖(如tomcat-embed-core)的版本冲突
  • 若发现冲突,通过<exclusions>标签排除冗余依赖版本

内容的提问来源于stack exchange,提问作者TrynaLearnMath

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 11:01:34