springBoot Maven改成war包
程序员文章站
2024-02-07 16:42:40
...
1.在项目的pom.xml中添加
<packaging>war</packaging>
<dependencies>
//自己对比下,缺哪些
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 移除嵌入式tomcat插件 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--移除自带的tomcat-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
2.修改启动类 新建SpringBootStartApplication类
package com.xianbaovip.project;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class SpringBootStartApplication extends SpringBootServletInitializer {
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){
//ProjectApplication为原来的启动类
return builder.sources(ProjectApplication.class);
}
}
3.打包
4.查看 在target目录下
上一篇: springboot工程打包
推荐阅读
-
SpringBoot打war包部署Tomacat
-
SpringBoot 打war包并部署到Tomcat
-
springBoot Maven改成war包
-
springboot项目打成jar包可运行,但打成war包无法运行
-
Springboot打包项目为war包或jar包
-
springboot项目打包成jar或war包的方式(引用了本地jar包的)
-
如何使用IDEA将maven项目打成war包,并部署到tomcat服务器上
-
SpringBoot项目打jar包war包部署到Tomcat服务器
-
IDEA 将 SpringBoot 的项目打包成 war包
-
springboot 项目打成war包部署到tomcat下