SpringBoot是内置tomcat服务器的,如果想使用jetty服务器的话,需要先把tomcat服务器排除在外
在pom.xml中添加如下代码
<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>
添加上面代码的exclusions包裹的代码,这一步是为了把tomcat排除出去
接下来添加如下依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
运行程序即可