1.修改pom文件把打包方式改为war
<packaging>jar</packaging>
2.去掉pom中spring-boot-starter-web中内嵌的tomcat
搜索tomcat
选中右键exclude内嵌的tomcat
3.再添加tomcat支持包如下
<!-- tomcat支持包-->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>8.0.36</version>
<scope>provided</scope>
</dependency>
<!--外置tomcat启动-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
4.然后直接使用maven 的package命令即可打包为war包