springboot支持三种嵌入式servlet容器:tomcat(默认),jetty,undertow_spring

默认是使用tomcat容器的:

springboot支持三种嵌入式servlet容器:tomcat(默认),jetty,undertow_spring_02

web模块排除tomcat依赖:

springboot支持三种嵌入式servlet容器:tomcat(默认),jetty,undertow_spring_03

引入jetty容器:

springboot支持三种嵌入式servlet容器:tomcat(默认),jetty,undertow_spring_04

启动项目看日志(已经成功切换到jetty):

springboot支持三种嵌入式servlet容器:tomcat(默认),jetty,undertow_spring_05

关键是,与tomcat保持一样的配置(一样的配方,不一样的味道):

springboot支持三种嵌入式servlet容器:tomcat(默认),jetty,undertow_spring_06

再整体来看一下:

springboot支持三种嵌入式servlet容器:tomcat(默认),jetty,undertow_spring_07

再比如,切换成undertow容器:

springboot支持三种嵌入式servlet容器:tomcat(默认),jetty,undertow_spring_08

springboot支持三种嵌入式servlet容器:tomcat(默认),jetty,undertow_spring_09

看日志,已经成功切换到undertow了:

springboot支持三种嵌入式servlet容器:tomcat(默认),jetty,undertow_spring_10