首页 > 解决方案 > spring boot 应用程序重新启动并显示消息“Tomcat 已启动”

问题描述

我有一个 spring-boot 应用程序(spring-boot 1.5.9.RELEASE),它会在任何时间点随机重启(或者看起来像是从日志中重启)。请参阅下面的日志。

  1. 我没有启用 devtools
  2. 我没有启用 jmxremote
  3. 我不调用 make /refresh 调用
  4. 我确实使用弹簧云配置

但应用程序仍会在不到一小时内重新启动(有时在 3 分钟内)

2018-05-28 09:50:43.108  INFO [pool-3-thread-3] myclass1 : myMessage1
2018-05-28 09:50:43.112  INFO [pool-2-thread-2] myclass2 : myMessage2
2018-05-28 09:50:43.118  INFO [pool-1-thread-3] myclass3 : myMessage3
2018-05-28 09:50:43.214  INFO [main] TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2018-05-28 09:50:43.221  INFO [main] Application                      : Started Application ... ... ...

标签: javaspringspring-boottomcatrestart

解决方案


如果你想确保你的 Spring Boot 应用程序中没有启动 Web 服务器,你可以设置以下配置键

spring.main.web-environment=false 或者你可以使用 SpringApplicationBuilder

新的 SpringApplicationBuilder(YourApp.class) .web(false).run(args);


推荐阅读