- 去除Spring-boot-start-web中的Tomcat的依赖
<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>
- 修改POM中的<packaging>jar</packaging> 为 <packaging>war</packaging>
- 添加Servlet的依赖包
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
- 启动类继承 extends SpringBootServletInitializer
覆盖 configure方法
将builder的sources中的启动指向原来的启动类
例如