Unable to start embedded Tomcat错误解决

@TOCUnable to start embedded Tomcat错误解决
最近在学习springcloud,都是原理,自己搭建下看看,当然是先从eurika开始,遇到报错如下(内容太多就不全部贴出来了):

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-5.2.4.RELEASE.jar:5.2.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]
at com.gupao.gun.GunApplication.main(GunApplication.java:13) ~[classes/:na]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126) ~[spring-boot-2.2.5.RELEASE.jar:2.2.5.RELEASE]

网上搜索了一下,都说是springcloud版本和springboot版本不一致引起的
我使用的springcloud版本是Hoxton.SR3, 网上搜索得知对应springboot 2.2.X,好统一修改2.2.5,但是还是报错,思路没转换过来,继续在这个方向上纠结,会不会是版本太新的原因呢,把springcloud换成热门版本Greenwich.SR3,spirngboot换成2.1.9,悲剧,引起之前构建的其他幻境的报错,想想还是恢复Hoxton.SR3版本,纠结了几个小时,想起pom中引用了这么一段

 <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            <version>2.1.3.RELEASE</version>
        </dependency>

会不会是eureka组件与springcloud版本不一致呢,到maven官网去搜索Spring Cloud Dependencies,找到Hoxton.SR3,下拉,看到:
Unable to start embedded Tomcat错误解决_第1张图片
之前也看到这,但是没看懂,根据我引用的组件在netflix下,所以猜测是我标出的位置,于是把版本换成了:

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            <version>2.2.2.RELEASE</version>
        </dependency>

问题解决

总结
springcloud的版本不光要与springboot版本对应,组件版本也需要与大版本一致,希望遇到相同问题的朋友可以节约时间。

你可能感兴趣的:(bug处理)