Spring Boot内置容器
SpringBoot内置容器
Spring Boot集成的嵌入式容器主要有以下几种:
Tomcat、Jetty、Undertow、Netty、Webflux
Spring Boot默认支持的容器
Spring Boot默认支持的容器主要有以下几种:
Tomcat、Jetty、Undertow
Spring Boot内置容器优势对比
1、Tomcat
Tomcat特性:
默认容器:Spring Boot默认的嵌入式容器,无需额外配置;
广泛支持:在各种应用场景下表现良好,适用于大多数Web应用;
成熟稳定:Tomcat是一个成熟且稳定的Servlet容器,广泛使用。
易于使用:Spring Boot集成简单,易于上手;
Spring Boot引入Tomcat依赖:
<!-- spring-boot-starter-web依赖中默认引入tomcat -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
2、Jetty
Jetty特性:
低资源消耗:Jetty内存占用相对较低,适用于资源有限的环境;
快速启动:Jetty启动速度较快,适用于开发和测试环境;
异步支持:Jetty支持非阻塞和异步处理,适用于高并发应用;
Spring Boot引入Jetty依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>