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>
 



posted @ 2019-08-05 15:23  忘聊寒  阅读(641)  评论(0编辑  收藏  举报