SpringBoot默认以Jar包的形式启动服务器,所以只需要替换Tomcat的Jar报包就行了
1. Tomcat 的 Jar 包在 spring-boot-starter-web 引入时被自动引入。
2. 剔除 Tomcat 并引入 Jetty 的 Jar 包
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
3. 启动项目即可