- SpringBoot项目,可以内置Tomcat、Jetty、Undertow、Netty等容器
- 添加spring-boot-starter-web依赖后,默认使用的是Tomcat作为内置容器。
- 可以在SpringBoot中嵌入Jetty作为容器,配置方式如下,排除掉spring-boot-starter-web中默认的tomcat内嵌容器,在引入jetty的依赖即可。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
- 可以在SpringBoot中嵌入Undertow作为容器,配置方式如下,排除掉spring-boot-starter-web中默认的tomcat内嵌容器,在引入Undertow的依赖即可。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>