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
springboot自带的web容器

原文地址: https://www.cveoy.top/t/topic/i1ZI 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录