- Published on
springboot 打war包
- Authors
- Name
- JiGu
- @crypto20x
在引入springboot依赖的地方,pom引入如下配置:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
在需要打包的项目下面加入如下配置:
<packaging>war</packaging>
......
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
加入一个新类,重写configure函数
package com.grgbanking;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class GbServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(GbApplication.class);//这里是启动类的class
}
}
mvn clean install 就生成war包了
参考链接: Springboot项目打成war包教程_springboot打war包_珠光的博客-CSDN博客 三分钟把spring boot打成war包部署到tomcat中 - 掘金 (juejin.cn)
Spring Boot外置WAR包东方通TongWeb部署问题_spring boot_ZQB765720343-华为云开发者联盟 (csdn.net) 信创迁移适配实战-SpringBoot项目打包war部署至TongWeb7 - 掘金 (juejin.cn)