1 報錯信息
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2020-12-01 23:46:25.130 ERROR 15644 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.3.1.jar:5.3.1] at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.1.jar:5.3.1] at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.3.1.jar:5.3.1] at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_77] at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring-context-5.3.1.jar:5.3.1] at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.3.1.jar:5.3.1] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:942) ~[spring-context-5.3.1.jar:5.3.1] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:591) ~[spring-context-5.3.1.jar:5.3.1] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.0.jar:2.4.0] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) [spring-boot-2.4.0.jar:2.4.0] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.4.0.jar:2.4.0] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) [spring-boot-2.4.0.jar:2.4.0] at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) [spring-boot-2.4.0.jar:2.4.0] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309) [spring-boot-2.4.0.jar:2.4.0] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298) [spring-boot-2.4.0.jar:2.4.0] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_77] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_77] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_77] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_77] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.4.0.jar:2.4.0] Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229) ~[spring-boot-2.4.0.jar:2.4.0] at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43) ~[spring-boot-2.4.0.jar:2.4.0] at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) ~[spring-context-5.3.1.jar:5.3.1] ... 20 common frames omitted Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed at org.apache.catalina.core.StandardService.addConnector(StandardService.java:231) ~[tomcat-embed-core-9.0.39.jar:9.0.39] at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282) ~[spring-boot-2.4.0.jar:2.4.0] at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213) ~[spring-boot-2.4.0.jar:2.4.0] ... 22 common frames omitted Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed at org.apache.catalina.connector.Connector.startInternal(Connector.java:1067) ~[tomcat-embed-core-9.0.39.jar:9.0.39] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.39.jar:9.0.39] at org.apache.catalina.core.StandardService.addConnector(StandardService.java:227) ~[tomcat-embed-core-9.0.39.jar:9.0.39] ... 24 common frames omitted Caused by: java.net.BindException: Cannot assign requested address: bind at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_77] at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_77] at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_77] at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_77] at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_77] at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:228) ~[tomcat-embed-core-9.0.39.jar:9.0.39] at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:211) ~[tomcat-embed-core-9.0.39.jar:9.0.39] at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1141) ~[tomcat-embed-core-9.0.39.jar:9.0.39] at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1227) ~[tomcat-embed-core-9.0.39.jar:9.0.39] at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:592) ~[tomcat-embed-core-9.0.39.jar:9.0.39] at org.apache.catalina.connector.Connector.startInternal(Connector.java:1064) ~[tomcat-embed-core-9.0.39.jar:9.0.39] ... 26 common frames omitted
2 問題排查:
2.a 是否是自己修改了哪個文件?導致報錯
由於本人初學springboot,學習上一節時,springboot還可以正常啟動,但是在學習freemarker之后,就不行了。
排查方法:按照intelligentidea 進行快照還原,還原到上一版時點,進行重啟,發現還是不行,無法啟動。
2.b 是否是pom.xml導入的依賴導致?
最開是的問題是freemarker,引用的properties配置文件的中文亂碼,百度說用yml不會亂碼,自己進行了嘗試yml,是否是因為pom.xml 引入了依賴,后來雖然依賴刪除了,但是相關jar包資源還在?(事實上是我多想了,當時沒有在pom.xml引入相關依賴)
排查方法:idea找到對應的maven導入jar包的路徑,全部清空。然后重新保存pom.xml(自動導入jar包)。然並卵。
2.c 實在沒有辦法了,FQ找,這種問題我看大部分都是端口,配置文件什么的,但是自己的端口又沒有被占用啊。沒辦法,再查查吧
排查方法:win10 以管理員身份運行命令窗口,netstat -ano|findstr 808*,結果也沒有看到相關的端口被占用,沒辦法,這個端口占用的又被排除了。
2.d 端口沒問題了,是不是ip有問題呢?因為以前學習的是server端的配置,有綁定ip的時候根據ipv4去配置的,沒有用localhost或者127.0.0.1,
排查方法:重新查看ipv4,在application.properties中進行修改,重新啟動,問題解決。
3 總結:
總結了下,上次學習的時候在國圖,電腦連的是手機開的熱點,遇到問題的時候是在家里,練的wifi。所以ipv4的網址是變動的(而我以前一直認為ipv4是不變的),這也是最大的收獲吧!花了兩天,解決出來了一個問題啊