Spring boot Unable to start embedded Tomcat报错 java.lang.NoSuchMethodError: javax.servlet.ServletCont...
时间: 2024-05-13 13:18:58 浏览: 21
这个错误通常是由于 Tomcat 和 Servlet API 版本不兼容引起的。可以尝试以下几个解决方案:
1.检查你的项目的依赖关系,确保 Servlet API 版本与 Tomcat 版本匹配。
2.尝试升级你的 Servlet API 版本,以匹配最新的 Tomcat 版本。
3.尝试降级你的 Tomcat 版本,以匹配 Servlet API 的版本。
4.如果你使用的是 Maven,可以尝试在 pom.xml 文件中添加以下依赖项:
```
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
```
其中,`provided` 表示这个依赖在运行时不会被打包进你的项目中,因为 Tomcat 已经提供了这个 API。
希望以上解决方案能够帮助你解决问题。
相关问题
org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat at org.springframe
根据提供的引用内容来看,问题出现在启动嵌入式Tomcat时。错误信息是"org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat"。原因是在应用程序的依赖中引用了Jackson相关的包,但是没有引用完整。你可以通过添加完整的依赖来解决这个问题。解决方案中提到添加以下依赖:
```
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.3</version>
<scope>compile</scope>
</dependency>
```
同时,你还需要在这个依赖中添加排除规则,以防止冲突:
```
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
</exclusions>
```
另外,还需要添加Jackson Annotations的依赖:
```
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.8</version>
</dependency>
```
这样就可以解决引起Tomcat启动失败的问题了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [【图文详解】SpringBoot启动报错:Unable to start web server; nested exception is org.springframework...](https://blog.csdn.net/weixin_42168713/article/details/126407440)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [搭建nacos集群启动时,报错Unable to start web... nested exception is org.springframework.boot.web.server](https://blog.csdn.net/qq_36220273/article/details/126786824)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
Spring boot Unable to start embedded Tomcat
Spring boot Unable to start embedded Tomcat报错 java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()是由于缺少javax.servlet.ServletContext.getVirtualServerName()方法引起的。解决这个问题的方法是将Tomcat安装目录下的servlet-api.jar复制到JDK安装目录下的/jre/lib/ext目录中。这样就可以解决该问题。\[3\]
#### 引用[.reference_title]
- *1* *2* *3* [问题解决:Spring boot Unable to start embedded Tomcat报错](https://blog.csdn.net/awsl8694/article/details/128918613)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)