spring boot打war包的修改内容

//修改启动类
//增加引入:
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.web.WebApplicationInitializer;
//类名那一行增加继承和实现:
extends SpringBootServletInitializer implements WebApplicationInitializer    

//重写configure方法:
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
  return application.sources(XXXApplication.class); //XXXApplication修改为类名
}

//修改pom.xml
//修改war类型:
<packaging>war</packaging>

//增加依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
 



原文地址:https://www.cnblogs.com/wangliaohan/p/11270057.html