spring boot 打包问题
一、jar包
1.maven build package
2.linux 下执行 java -jar & 命令后台运行,也可加入服务运行
二、war包
1.将pom中的<packaging>jar</packaging> 改为<packaging>war</packaging>
2增加下面依赖覆盖内嵌的tomcat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
3.增加ServletInitializer类
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
setRegisterErrorPageFilter(false);
return application.sources(BrandAuditApplication.class);
}
}