spring boot 无法启动

spring boot 使用内置tomcat 报错  :

Unable to start embedded Tomcat servlet container

 Tomcat connector in failed state ;

debug 进入 代码 中发现 走 this.tomcat.stop 这句代码报错。。 字面理解 应该是 tomcat 无法正常停止 。。。

然后百度 查到了一篇英文 验证了我的猜测: 

The maven process does terminate but Tomcat is still running and I can still hit the web-page. When I try to start spring-boot again it fails to start Tomcat because the port is in use.

大致意思 是 tomcat 没有正常停止,再次启动提示 port 端口仍在使用。(可以通过访问你的服务判断如 localhost:8080/MES)

我的原因应该是: eclipse 崩溃,tomcat 没有正常关闭。

结合 https://github.com/spring-projects/spring-boot/issues/773    是 spring-boot 的一个bug..

解决方案是 http://stackoverflow.com/questions/23432651/terminating-mvn-spring-bootrun-doesnt-stop-tomcat

总结有如下方案(最终目的都是关闭tomcat进程):

1.

命令行:  netstat -ano | find "8080"  换成你的端口号 

taskkill /F /PID 1196 杀死进程

 c:>netstat -ano | find "8080"
     TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       1196
     TCP    [::]:8080              [::]:0                 LISTENING       1196
     c:>taskkill /F /PID 1196
     SUCCESS: The process with PID 1196 has been terminated.

2. 换个端口号启动 : 更改spring boot 配置 server.port=7778

    
原文地址:https://www.cnblogs.com/zhangchenglzhao/p/6401051.html