Spring Boot 内嵌 Web 容器:Tomcat、Jetty 和 Undertow
Spring Boot 默认使用的是 Tomcat 作为内嵌的 Web 容器。除了 Tomcat,Spring Boot 还支持 Jetty 和 Undertow 作为内嵌的 Web 容器。可以通过在 pom.xml 文件中添加相应的依赖来切换使用不同的 Web 容器。例如,如果要使用 Jetty 作为内嵌的 Web 容器,可以添加以下依赖:
<dependencies>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
...
</dependencies>
然后在 application.properties 文件中配置使用 Jetty:
server.port=8080
server.servlet.container=jetty
原文地址: https://www.cveoy.top/t/topic/oool 著作权归作者所有。请勿转载和采集!