新建一个类或者让主方法的类继承SpringBootServletInitializer ,重写configure方法,
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(application.Class);
}
private static ClassapplicationClass = ServletInitializer.class;
pom添加依赖
packaging改成war