一、修改项目打包方式为war包
修改pom.xml文件中packaging属性项
<packaging>war</packaging>
修改pom.xml文件增加一个依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
修改启动类
public class SpringBootStartApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { // 注意这里要指向原先用main方法执行的Application启动类 return builder.sources(Application.class); } }
二、打包
执行Maven打包命令打包即可生成war包,然后即可用于部署Tomcat
mvn clean package