一、pom文件中修改packaging形式
<packaging>war</packaging>
二、引入servlet依赖
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
三、启动类继承 SpringBootServletInitializer
@SpringBootApplication
public class Demo2Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Demo2Application.class, args);
}
}
四、将war部署到本地tomcat webapps 目录下
启动tomcat验证