我尝试使用 netstat -aon | findstr 8088
查找端口未找到。
应用程序属性:
server.host=localhost
server.port=8088
server.context-path=/
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%t %a "%r" %s (%D ms)
控制台输出无任何错误日志:(JDK8 + IDEA + WIN7)
2018-02-11 17:10:26.374 [main] INFO o.s.b.c.e.tomcat.TomcatEmbeddedServletContainer - Tomcat initialized with port(s): 8088 (http)
2018-02-11 17:10:26.383 [main] INFO org.apache.catalina.core.StandardService - Starting service [Tomcat]
2018-02-11 17:10:26.384 [main] INFO org.apache.catalina.core.StandardEngine - Starting Servlet Engine: Apache Tomcat/8.5.16
2018-02-11 17:10:26.510 [localhost-startStop-1] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2018-02-11 17:10:26.510 [localhost-startStop-1] DEBUG org.springframework.web.context.ContextLoader - Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT]
2018-02-11 17:10:26.510 [localhost-startStop-1] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 1636 ms
最后,我换了一个已经使用过的端口,然后启动应用程序,它仍然打印成功日志,大声笑,找不到任何错误日志,我如何找到问题?
最佳答案
是的,我自己找到了原因,一个@Bean阻塞了spring init主线程,tomcat还没有绑定(bind)。这很荒谬。这个 bean 是 netty,我必须改变另一种方式初始化。
关于java - spring boot tomcat初始化成功但找不到监听端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48730172/