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

Spring Boot应用启动未显示Tomcat日志及运行端口问题排查

Spring Boot启动无Tomcat端口日志、Web接口无法访问问题排查

问题表现

  • 应用已集成消息队列监听器、健康检查Controller,启动流程无报错,消息消费逻辑可正常运行
  • 启动日志无内嵌Tomcat初始化、端口绑定相关记录,所有HTTP接口(含健康检查接口)无法访问,导致服务部署阻塞

问题服务启动日志如下:

2022-07-15 15:39:24.628  INFO [bo-bse-permissible-users-job,,,] 226627 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.3.7.Final}
2022-07-15 15:39:24.630  INFO [bo-bse-permissible-users-job,,,] 226627 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2022-07-15 15:39:24.789  INFO [bo-bse-permissible-users-job,,,] 226627 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2022-07-15 15:39:24.940  INFO [bo-bse-permissible-users-job,,,] 226627 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2022-07-15 15:39:25.888  INFO [bo-bse-permissible-users-job,,,] 226627 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-07-15 15:39:26.911  INFO [bo-bse-permissible-users-job,,,] 226627 --- [           main] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
2022-07-15 15:39:28.112  INFO [bo-bse-permissible-users-job,,,] 226627 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'threadPoolTaskExecutorForPlatformStatus'
2022-07-15 15:39:33.946  INFO [bo-bse-permissible-users-job,,,] 226627 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService
2022-07-15 15:39:34.182  INFO [bo-bse-permissible-users-job,,,] 226627 --- [           main] c.p.e.bo.BoBsePermissibleApplication     : Started BoBsePermissibleApplication in 16.853 seconds (JVM running for 17.168)

同架构、依赖基本一致的正常服务启动时,会输出如下Tomcat相关日志:

2022-07-15 15:43:57.812  INFO 227112 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8000 (http)
2022-07-15 15:43:57.813  INFO 227112 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-07-15 15:43:57.813  INFO 227112 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.16]
2022-07-15 15:43:57.819  INFO 227112 --- [           main] o.a.c.c.C.[Tomcat-1].[localhost].[/]     : Initializing Spring embedded WebApplicationContext
2022-07-15 15:43:57.819  INFO 227112 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 77 ms
2022-07-15 15:43:57.843  INFO 227112 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 26 endpoint(s) beneath base path '/actuator'
2022-07-15 15:43:57.912  INFO 227112 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8000 (http) with context path ''
2022-07-15 15:43:57.932  INFO 227112 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 5555 (http) with context path ''
2022-07-15 15:43:57.933  INFO 227112 --- [           main] c.p.b.e.BoConsumerExchangeAckApplication : Started BoConsumerExchangeAckApplication in 13.602 seconds (JVM running for 13.873)

初步排查

已确认问题服务的依赖包中存在完整的Tomcat内嵌相关jar:

  • tomcat-embed-core-9.0.16.jar
  • tomcat-embed-el-9.0.16.jar
  • tomcat-embed-websocket-9.0.16.jar

排除依赖缺失导致Web容器无法初始化的可能。

根因与解决

根因

application.properties配置文件中存在配置项:

spring.main.web-application-type=none

该配置会显式告知Spring Boot当前应用为非Web应用,启动流程中不会初始化任何内嵌Web容器(包括Tomcat),因此不会输出Tomcat启动日志,也不会对外提供HTTP服务。

修复方案

直接移除上述配置项即可,Spring Boot会根据classpath下的依赖自动识别为Servlet Web应用,自动初始化Tomcat容器。
如果需要显式指定应用类型,也可以将配置值修改为servlet:

spring.main.web-application-type=servlet

配置修改后重启服务,即可正常看到Tomcat启动、端口绑定的日志,健康检查等所有Controller接口都可正常访问。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.26 19:06:43