Spring Boot 支持的内嵌容器有 Tomcat(默认) 、Jetty 、Undertow 和 Reactor Netty (v2.0+), 借助可插拔 (SPI) 机制的实现,开发者可以轻松进行容器间的切换。
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 排除默认的Tomcat依赖 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 引入Jetty 或 Undertow 或 Reactor Netty -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</depend