根据每个公司的不同习惯,有的时候需要切换spring boot的默认的Servlet 容器,比如我就比较青睐于Jetty,下面是我的替换的pom中d的配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- Exclude the Tomcat dependency -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Use Jetty instead -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
PS:为什么要强制不引用Tomcat容器,那是因为Tomcat的装载的顺序比较靠前,如果不排除的话,即使引入了jetty的starter,最终使用的容器还是Tomcat