springboot配置内置tomcat
时间: 2023-09-09 15:11:06 浏览: 146
Springboot使用内置tomcat作为默认的web容器,无需额外安装Tomcat,只需在服务部署时直接启动jar包即可。这是因为在spring-boot-starter-web中,默认导入的是tomcat,所以启动时使用的web容器就是tomcat。如果你想配置使用其他的web容器,比如Undertow,可以按照以下步骤进行操作:
1. 修改pom.xml文件,排除默认引入的spring-boot-starter-tomcat依赖,并添加Undertow依赖:
```xml
<dependencies>
<!-- 导入web场景启动器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 排除tomcat starter -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 引入undertow -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
</dependencies>
```
通过这样的配置,你就可以使用Undertow作为springboot的内置web容器了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [SpringBoot如何使用内嵌Tomcat](https://blog.csdn.net/u011523825/article/details/126114624)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [SpringBoot内置Tomcat的配置和切换](https://blog.csdn.net/weixin_39158966/article/details/129745702)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文