<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>
若是使用Jetty容器,那麼添加web
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jetty</artifactId> </dependency>
若是使用Undertow容器,那麼添加spring
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-undertow</artifactId> </dependency
在啓動類,添加tomcat
@Bean public EmbeddedServletContainerFactory servletContainer() { JettyEmbeddedServletContainerFactory factory = new JettyEmbeddedServletContainerFactory(); return factory; }
若是你想換成Undertow,那麼把上面中Jetty五個字母替換成Undertowspring-boot
在啓動類添加spa
@Bean public ServletWebServerFactory servletContainer() { JettyServletWebServerFactory tomcat = new JettyServletWebServerFactory(); return tomcat; }
若是你想換成Undertow,那麼把上面中Jetty五個字母替換成Undertowservlet