SpringBoot 默认针对Servlet容器提供以下支持:
Tomcat(默认使用)
Jetty :支持长连接项目(如:聊天页面)
Undertow : 不支持 JSP , 但是并发性能高,是高性能非阻塞的容器
1.pom.xml移除默认容器
方法:进入pom.xml-》右键-》Diagrams-》show Depencies-》1:1-》选中移除项目-》exclude
warning:可能exclude是灰色的,点击旁边空白,再点击exclude即可
移除后pom.xml显示
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!--移除tomcat启动器-->
<exclusions>
<exclusion>
<artifactId>spring-boot-starter-tomcat</artifactId>
<groupId>org.springframework.boot</groupId>
</exclusion>
</exclusions>
</dependency>
2.jetty容器,pom.xml配置就好
<!--引入jetty的Servlet容器-->
<dependency>
<artifactId>spring-boot-starter-jetty</artifactId>
<groupId>org.springframework.boot</groupId>
</dependency>
3.undertow,pom.xml配置就好
<!--undertow启动器-->
<dependency>
<artifactId>spring-boot-starter-undertow</artifactId>
<groupId>org.springframework.boot</groupId>
</dependency>
运行时,idea下方会显示相应容器