1.指定war打包方式jar
2.pom.xml添加spring-boot-maven-plugin插件
org.springframework.boot
spring-boot-maven-plugin
2.0.1.RELEASE
repackage
3.pom.xml添加spring-boot-starter-tomcat依赖
org.springframework.boot
spring-boot-starter-tomcat
provided
4.启动类继承SpringBootServletInitializer并重写configure方法@SpringBootApplication
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}