1. 修改项目打包方式
2. 排除springboot自带的tomcat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>2.5.3</version>
<scope>provided</scope>
</dependency>
3. 修改启动相关代码
在启动类同级目录下创建新的类
package net.lesscoding;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* @author eleven
* @date 2021/8/15 19:58
* @apiNote war包启动类
*/
public class SpringBootStarterApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(NginxDemoApplication.class);
}
}