版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/nangeali/article/details/82729578
切换Servlet容器
Spring boot默认配置Tomcat作为Servlet容器
引入web模块,默认使用嵌入式的Tomcat
可以切换Jetty、Undertow
默认配置
Pom文件,查看依赖关系
默认使用Tomcat
因为,Web引入了Tomcat的启动器
切换Jetty
Pom文件,排除Tomcat启动器依赖
在依赖关系,右键可以排除依赖
<!-- 引入web模块 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
引入Jetty启动器
<!--引入其他的Servlet容器-->
<dependency>
<artifactId>spring-boot-starter-jetty</artifactId>
<groupId>org.springframework.boot</groupId>
</dependency>
切换undertow
引入undertow启动器
<!--引入其他的Servlet容器-->
<dependency>
<artifactId>spring-boot-starter-undertow</artifactId>
<groupId>org.springframework.boot</groupId>
</dependency>