如何排查并解决Spring Boot集成Tomcat启动失败的问题?

2026-05-16 05:042阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计613个文字,预计阅读时间需要3分钟。

如何排查并解决Spring Boot集成Tomcat启动失败的问题?

本文记录了一次Spring Boot通过main方法启动失败的问题:Unregistering JMX-exposed beans on shutdown。由于已解决的他人截图效果相同,但百度一圈都说Tomcat没有配置,以下是具体分析。

问题现象:Spring Boot通过main方法启动时,报错Unregistering JMX-exposed beans on shutdown。

原因分析:可能是Tomcat没有配置JMX。

解决方案:

1. 检查Tomcat的server.xml配置文件,确保JMX配置正确。

2. 修改Spring Boot的application.properties或application.yml文件,关闭JMX。

示例:

application.properties

properties关闭JMXmanagement.endpoints.web.exposure.include=

application.yml

yaml关闭JMXmanagement: endpoints: web: exposure: include:

此文章记录一次spring boot通过main 方法启动无法成功的问题

Unregistering JMX-exposed beans on shutdown

问题如下,因为已经解决用的别人的截图但是效果是一样的

百度了一圈都说tomcat没有配置,但实际xml有如下配置

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </dependency>

问题:eclipse maven自动下jar包时下载的不全,有部分文件丢失,但是控制台并没有发出任何 classNotFound提示

解决:C:\Users\Administrator\.m2\repository\org\apache\tomcat\embed

讲该目录下的所有文件删除,然后右键项目maven-> update project,

其他同类发现classNotFound也可以通过寻找对应jar包在本地仓库位置,使用相同操作进行解决

补充知识:springboot 设置web和非web启动

如何排查并解决Spring Boot集成Tomcat启动失败的问题?

springBoot区分web和非web项目

老版本:

#server config #web_environment是否是web项目 spring.main.web_environment=true #是否加载springboot banner spring.main.show_banner=false

现版本:

#server config #是否设定web应用,none-非web,servlet-web应用 spring.main.web-application-type=servlet #加载springboot banner的方式:off-关闭,console-控制台,log-日志 spring.main.banner-mode=off

WebApplicationType原理:

public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) { this.resourceLoader = resourceLoader; Assert.notNull(primarySources, "PrimarySources must not be null"); this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources)); this.webApplicationType = deduceWebApplicationType(); setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class)); setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class)); this.mainApplicationClass = deduceMainApplicationClass(); }

deduceWebApplicationType()推断当前环境是哪种Web环境(Servlet、Reactive),或者不是Web环境,判断逻辑为Classpath是够有以下类:

存在org.springframework.web.reactive.DispatcherHandler且不存在org.springframework.web.servlet.DispatcherServlet为WebApplicationType.REACTIVE;

同时存在javax.servlet.Servlet、org.springframework.web.context.ConfigurableWebApplicationContext 为WebApplicationType.SERVLET;

否则为 WebApplicationType.NONE

在这里this.webApplicationType = WebApplicationType.SERVLET;

所谓的banner就是控制台打印的一堆线组成的spring

以上这篇解决Spring boot 嵌入的tomcat不启动问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。

标签:Tomcat

本文共计613个文字,预计阅读时间需要3分钟。

如何排查并解决Spring Boot集成Tomcat启动失败的问题?

本文记录了一次Spring Boot通过main方法启动失败的问题:Unregistering JMX-exposed beans on shutdown。由于已解决的他人截图效果相同,但百度一圈都说Tomcat没有配置,以下是具体分析。

问题现象:Spring Boot通过main方法启动时,报错Unregistering JMX-exposed beans on shutdown。

原因分析:可能是Tomcat没有配置JMX。

解决方案:

1. 检查Tomcat的server.xml配置文件,确保JMX配置正确。

2. 修改Spring Boot的application.properties或application.yml文件,关闭JMX。

示例:

application.properties

properties关闭JMXmanagement.endpoints.web.exposure.include=

application.yml

yaml关闭JMXmanagement: endpoints: web: exposure: include:

此文章记录一次spring boot通过main 方法启动无法成功的问题

Unregistering JMX-exposed beans on shutdown

问题如下,因为已经解决用的别人的截图但是效果是一样的

百度了一圈都说tomcat没有配置,但实际xml有如下配置

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </dependency>

问题:eclipse maven自动下jar包时下载的不全,有部分文件丢失,但是控制台并没有发出任何 classNotFound提示

解决:C:\Users\Administrator\.m2\repository\org\apache\tomcat\embed

讲该目录下的所有文件删除,然后右键项目maven-> update project,

其他同类发现classNotFound也可以通过寻找对应jar包在本地仓库位置,使用相同操作进行解决

补充知识:springboot 设置web和非web启动

如何排查并解决Spring Boot集成Tomcat启动失败的问题?

springBoot区分web和非web项目

老版本:

#server config #web_environment是否是web项目 spring.main.web_environment=true #是否加载springboot banner spring.main.show_banner=false

现版本:

#server config #是否设定web应用,none-非web,servlet-web应用 spring.main.web-application-type=servlet #加载springboot banner的方式:off-关闭,console-控制台,log-日志 spring.main.banner-mode=off

WebApplicationType原理:

public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) { this.resourceLoader = resourceLoader; Assert.notNull(primarySources, "PrimarySources must not be null"); this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources)); this.webApplicationType = deduceWebApplicationType(); setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class)); setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class)); this.mainApplicationClass = deduceMainApplicationClass(); }

deduceWebApplicationType()推断当前环境是哪种Web环境(Servlet、Reactive),或者不是Web环境,判断逻辑为Classpath是够有以下类:

存在org.springframework.web.reactive.DispatcherHandler且不存在org.springframework.web.servlet.DispatcherServlet为WebApplicationType.REACTIVE;

同时存在javax.servlet.Servlet、org.springframework.web.context.ConfigurableWebApplicationContext 为WebApplicationType.SERVLET;

否则为 WebApplicationType.NONE

在这里this.webApplicationType = WebApplicationType.SERVLET;

所谓的banner就是控制台打印的一堆线组成的spring

以上这篇解决Spring boot 嵌入的tomcat不启动问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。

标签:Tomcat