1、启动类继承SpringBootServletInitializer 重写 configure方法
@SpringBootApplication
public class DataTransmissionApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(DataTransmissionApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DataTransmissionApplication.class);
}
}
2、去除内置Tomcat
在pom文件中加入
<!-- 去除内置Tomcat -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
3、将文件改成war,更改pom配置
<packaging>war</packaging>
4、使用maven 打包
在项目的target中可以找到打包后的war文件