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

Ubuntu环境下Tomcat部署Spring Boot项目时Spring无法启动问题求助

问题排查点

1. 修正数据库连接URL配置

你当前application.properties中的MySQL连接URL存在语法错误,缺少双斜杠:

# 错误写法
spring.datasource.url=jdbc:mysql:localhost:3306/project_db
# 正确写法
spring.datasource.url=jdbc:mysql://localhost:3306/project_db

该错误会导致Spring启动时无法初始化数据库连接池,触发启动失败问题。

2. 检查ServletInitializer类的包路径

确保ServletInitializer类和TestprojectApplication启动类处于同一个包路径下,否则Spring无法扫描到初始化器,不会触发Spring上下文的启动流程。

3. 验证外置Tomcat版本兼容性

Spring Boot 2.5.4依赖Servlet 4.0规范,要求外置Tomcat版本必须为9.0.x及以上,若使用Tomcat 8.x及更低版本,会出现兼容问题导致Spring Boot无法启动。

4. 检查日志输出配置

默认情况下Spring Boot的日志可能不会直接输出到Tomcat的控制台,你需要查看Tomcat根目录下logs/catalina.out文件,确认是否存在Spring Boot启动过程中的错误堆栈信息。

5. 确认war包打包正确性

执行mvn clean package命令打包后,检查target目录下生成的war包结构:

  • 正确的可部署war包根目录下会存在WEB-INF/lib-provided目录,存放 scope 为 provided 的依赖
  • 若打包生成的war包缺少Spring相关依赖,需要确认spring-boot-maven-plugin配置是否生效

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.06 08:18:01