Spring Boot 支持以下嵌入式容器(Servlet 容器):
-
Tomcat:
- Spring Boot 默认使用 Tomcat 作为其嵌入式的 Servlet 容器。通过引入
spring-boot-starter-web
依赖,Spring Boot 应用程序能够自动配置并启动一个嵌入式的 Tomcat 服务器。
- Spring Boot 默认使用 Tomcat 作为其嵌入式的 Servlet 容器。通过引入
-
Jetty:
- 若要使用 Jetty 作为嵌入式容器,可以移除对 Tomcat 的依赖,并引入
spring-boot-starter-jetty
。Jetty 是一个高性能、轻量级的 Web 服务器和 Servlet 容器。
- 若要使用 Jetty 作为嵌入式容器,可以移除对 Tomcat 的依赖,并引入
-
Undertow:
- 如果希望使用 Undertow,可以引入
spring-boot-starter-undertow
依赖。Undertow 是 JBoss 提供的一个灵活且高性能的 Web 服务器。
- 如果希望使用 Undertow,可以引入
截至我知识更新的时间点(2024年),上述是 Spring Boot 主要支持的三种嵌入式容器。不过,请注意实际可用的选项可能随着 Spring Boot 版本的更新而有所变化,建议查阅最新的官方文档以获取最准确的信息。