1、修改pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 移除嵌入式tomcat插件 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
<!-- 移除嵌入式tomcat插件 -->
</dependency>
<!-- 移除嵌入式tomcat插件同时需要增加servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<!-- 移除嵌入式tomcat插件同时需要增加servlet-api -->
2、修改启动类
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class WebDemoApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(WebDemoApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(WebDemoApplication.class);
}
}
//@SpringBootApplication
//public class WebDemoApplication {
//
// public static void main(String[] args) {
// SpringApplication.run(WebDemoApplication.class, args);
// }
//
//}