SpringBoot自动配置–切换内置服务器
1:SpringBoot内置服务器
Tomcat服务器
Jetty服务器
Netty服务器
Undertow服务器
2:SpringBoot默认使用的web服务器是Tomcat服务器
在spring-boot-starter-web的起步依赖中
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
源码在org\springframework\boot\autoconfigure\web\embedded
3:SpringBoot切换内置服务器(这里切换Jetty服务器为例)
在pom.xml中spring-boot-starter-web依赖下加入如下
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- 排除tomcat依赖-->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 引入jetty的依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
最后运行SpringBoot的引导类
end