## Spring Boot 打 war 包的步骤
1. 添加 spring-boot-start-tomcat 的 provided 依赖
```
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
```
2. 添加 maven-war-plugin 插件
```
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
```
3. 继承 SpringBootServletInitializer, 重写 config 方法
```
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(MainApplication.class);
}
```
原文地址:https://www.cnblogs.com/facous/p/9597202.html
时间: 2024-10-28 19:14:26