1、将
pom文件的packaging属性设置为war
<packaging>war</packaging>
2、添加servlet依赖,注意要看清楚tomcat服务器的版本,一定要版本一致
https://blog.csdn.net/zzy7075/article/details/61918776
3、去除
artifactId>spring-boot-starter-web</artifactId>
里面的tomcat依赖
dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!-- 移除嵌入式tomcat插件 --> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency>
4、再用maven插件打包