Spring WebFlux支持Netty,Undertow,Tomcat,Jetty和Servlet 3.1+容器。他们都适用于一个通用的Reactive Streams API。Spring WebFlux编程模型基于该通用API。
Spring WebFlux 默认是使用 Netty 作为 Web 容器的。如果要切换 Web 容器,只需要在 Maven 中做一下配置即可。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-netty</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 添加 tomcat依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<!-- <!– 添加 Undertow依赖 –>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
<!– 添加 jett依赖 –>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency> -->