SpringBoot 打war包并部署到Tomcat
程序员文章站
2024-02-07 16:42:28
...
1、移除Tomcat依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
2、添加servlet-api依赖
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
3、重写Application类
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
4、pom文件添加war包打包命令
<groupId>com.zhanghanlun</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>test</name>
<packaging>war</packaging>
5、maven打包
用IDEA的Maven图形界面进行打包
推荐阅读
-
SpringBoot打war包部署Tomacat
-
SpringBoot 打war包并部署到Tomcat
-
如何使用IDEA将maven项目打成war包,并部署到tomcat服务器上
-
maven项目打包成war格式(idea)并部署到Tomcat上
-
SpringBoot项目打jar包war包部署到Tomcat服务器
-
idea将web项目打成war包并运行到tomcat服务器上
-
springboot 项目打成war包部署到tomcat下
-
springboot项目打jar包部署到服务器IDEA
-
jenkins部署SpringBoot的jar包项目到docker容器并运行
-
springBoot项目打war包,部署到外部tomcat;解决打包后resources下的文件全部丢失