1.修改打包方式为 war
<packaging>war</packaging>
2. 修改tomcat 依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
3. 主类继承 SpringBootServletInitializer,实现 configure 方法
@SpringBootApplication
public class Application extends SpringBootServletInitializer{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(JobManagementApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(JobManagementApplication.class, args);
}
}
4.打包
mvn clean package -Dmaven.test.skip=true