1 first step
First, we need to change the packaging method in pom.xml to war
<packaging>jar</packaging>
<packaging>war</packaging>
Second step
Set the scope attribute of spring-boot-starter-tomcat to provided
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
third step
Add the ServletInitializer class to the startup class
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* 【api模块】
*
* @author yangjunxiong
* @date 2021/1/5 09:18
**/
@SpringBootApplication
@ServletComponentScan("com.yjx.project.runbatapi.web.listener")
public class RunBatApiApplication extends SpringBootServletInitializer {
the fourth step
Run the maven command package in the project root directory to package