一招搞定:Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
搭建springcloud项目,启动eureka的过程中出现了以下错误,该怎么办
Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
在百度上找了好几个版本的解决方案,就这个方案一招解决了我的难题:
出现错误的原因:
项目在加载的过程中,缺少了 jaxb-api 的包。
解决方案:
jaxb包是存储在jdk中的,但从java9开始,项目在加载的过程中便不再默认加载这个包了,所以此处我们需要在项目的pom.xml文件中手动添加依赖。
如果是java8 及以下的版本,可能就要寻找其他解决方案了。
代码如下,自取
<!-- 从java9开始,项目就不会默认加载jdk中的jaxb包,所以此处手动引入jaxb-api包 -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.2.10-b140310.1920</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
ok,问题解决,如果解决不了,就继续百度吧,肯定会找到解决方案的!