前提条件
1) 工程已经可以成功打成jar,并且运行
改造步骤
1) 在pom中增加如下配置
<packaging>war</packaging>
2)跟启动类同级增加类
DemoApplication替换成你的启动类
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DemoApplication.class);
}
}