1.修改pom.xml
修改pom.xml中打包方式为war包,将
<packaging>jar</packaging>
修改为:
<packaging>war</packaging>
2.修改启动类
两个步骤:
- 将启动类继承SpringBootServletInitializer
- 重写configure方法
@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(DemoApplication .class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(DemoApplication .class);
}
}
3.打包
运行Maven的【package】命令,在target目录下会生成war包。
至此,结束。