1.添加依赖到pom
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
2.修改启动类
@SpringBootApplication public class xxxApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(xxxApplication.class); } public static void main(String[] args) { SpringApplication.run(xxxApplication.class, args); } }
3.使用Intellij Idea
Build --> Build Artifacts --> 选择要打包编译的war --> 在项目target文件夹下出现新的war包
4.打包