錯誤信息:
org.apache.catalina.LifecycleException: Protocol handler start failed at org.apache.catalina.connector.Connector.startInternal(Connector.java:1008) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.addConnector(StandardService.java:227) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:263) at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:195) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:297) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) at com.uminton.AccountServerApplication.main(AccountServerApplication.java:18) Caused by: java.net.BindException: Cannot assign requested address: bind at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:433) at sun.nio.ch.Net.bind(Net.java:425) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:230) at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:213) at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1124) at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1210) at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:585) at org.apache.catalina.connector.Connector.startInternal(Connector.java:1005) ... 14 common frames omitted 2020-03-12 10:55:15.011 INFO o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2020-03-12 10:55:15.028 INFO ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2020-03-12 10:55:15.034 ERROR o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: The Tomcat connector configured to listen on port 8182 failed to start. The port may already be in use or the connector may be misconfigured. Action: Verify the connector's configuration, identify and stop any process that's listening on port 8182, or configure this application to listen on another port.
主要看最下面的錯誤大致意思是(google翻譯~~):
描述:
配置為監聽端口8081的Tomcat連接器啟動失敗。端口可能已經在使用中,或者連接器可能配置錯誤。
行動:
驗證連接器的配置,識別並停止在端口8081上偵聽的任何進程,或者將此應用程序配置為在另一個端口上偵聽。
解決端口被占用方法;
方法一:
1.打開cmd命令窗口 輸入如下指令查看所有端口和PID
netstat -ano
2.找到對應的端口對應的PID 輸入指令找到對應的進程
netstat -nao|findstr 8182
3.殺掉該進程 再次啟動就OK啦
taskkill /f /t /im java.exe #或者 javaw.exe
方法二:
跟方法一的步驟一一樣:先查找除對應被占用端口的PID
然后打開任務管理器,查找對應PID進程,結束任務即可
方法三:簡單粗暴
打開application.properties更改端口,用一個沒被占用的端口 server.port=8080
補充:
如果你application.properties配置了 server.address 配置的ip和本機ip不一樣,也會報上面的錯誤
(剛換了ip忘了改,改了端口,被坑了好久~~)