找了好久终于找到个有效的,而且简单,废话不多说
1.首先pom文件,jar包web自带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>
2.放入tomcat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
3.在pom文件内上面这里没有就,一般是没有的,有的就jar改成war
加<packaging>war</packaging>
<groupId>com.hhy</groupId>
<artifactId>spring-boot-01-cache</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>spring-boot-01-cache</name>
<description>Demo project for Spring Boot</description>
4.在Application文件内继承
extends SpringBootServletInitializer
public class SpringApplication extends SpringBootServletInitializer{
5.在启动类内重写方法
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringBoot01CacheApplication.class);
}
clean后package即可