SpringBoot項(xiàng)目如何打可執(zhí)行war包
最近做了一個(gè)Springboot項(xiàng)目,但是最后需要打成WAR包在容器中部署,下面就簡單記錄一下。
1、修改pom文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.eelve</groupId> <artifactId>springboot-war</artifactId> <version>0.0.1-SNAPSHOT</version> <!-- 打包方式 --> <packaging>war</packaging> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.6.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- 嵌入式tomcat相關(guān)jar將被放入到WEB-INF\lib-provided下 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <!-- 打包插件 --> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
2、修改啟動(dòng)類
package com.eelve.springboot.war; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServletInitializer; @SpringBootApplication public class SpringbootWarApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(SpringbootWarApplication.class); } public static void main(String[] args) { SpringApplication.run(SpringbootWarApplication.class, args); } }
使用maven打包(clean package),生成的war包可以用于傳統(tǒng)的部署方式(外部tomcat),也可以直接使用java -jar 的方式運(yùn)行。
到此這篇關(guān)于SpringBoot項(xiàng)目如何打可執(zhí)行war包的文章就介紹到這了,更多相關(guān)springboot打可執(zhí)行war包內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- springboot項(xiàng)目打成war包部署到tomcat遇到的一些問題
- Springboot打成war包并在tomcat中運(yùn)行的部署方法
- springboot web項(xiàng)目打jar或者war包并運(yùn)行的實(shí)現(xiàn)
- SpringBoot項(xiàng)目打成War包部署的方法步驟
- Spring Boot打war包的實(shí)例教程
- Spring Boot將項(xiàng)目打包成war包的操作方法
- SpringBoot中打war包需要注意事項(xiàng)
- SpringBoot項(xiàng)目打包war包時(shí)無法運(yùn)行問題的解決方式
相關(guān)文章
Java中excel表數(shù)據(jù)的批量導(dǎo)入方法
這篇文章主要為大家詳細(xì)介紹了Java中excel表數(shù)據(jù)的批量導(dǎo)入方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05Java線程狀態(tài)及切換、關(guān)閉線程的正確姿勢(shì)分享
這篇文章主要給大家介紹了關(guān)于Java線程狀態(tài)及切換、關(guān)閉線程的正確姿勢(shì),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者使用Java具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10java實(shí)現(xiàn)實(shí)時(shí)通信聊天程序
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)實(shí)時(shí)通信聊天程序,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-06-06用3個(gè)實(shí)例從原理到實(shí)戰(zhàn)講清楚Log4j史詩級(jí)漏洞
最近應(yīng)該很多人都在關(guān)注著一個(gè)漏洞Apache Log4j 2遠(yuǎn)程代碼執(zhí)行,該漏洞一旦被攻擊者利用會(huì)造成嚴(yán)重危害,這篇文章主要給大家介紹了關(guān)于如何用3個(gè)實(shí)例從原理到實(shí)戰(zhàn)講清楚Log4j史詩級(jí)漏洞的相關(guān)資料,需要的朋友可以參考下2021-12-12深入理解MyBatis中的一級(jí)緩存與二級(jí)緩存
這篇文章主要給大家深入的介紹了關(guān)于MyBatis中一級(jí)緩存與二級(jí)緩存的相關(guān)資料,文中詳細(xì)介紹MyBatis中一級(jí)緩存與二級(jí)緩存的工作原理及使用,對(duì)大家具有一定的參考性學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧。2017-06-06Spring中的ClassPathXmlApplicationContext源碼詳解
這篇文章主要介紹了Spring中的ClassPathXmlApplicationContext源碼詳解,ApplicationContext的主要實(shí)現(xiàn)類是ClassPathXmlApplicationContext和FileSystemXmlApplicationContext,前者默認(rèn)從類路徑加載配置文件,后者默認(rèn)從文件系統(tǒng)中裝載配置文件,需要的朋友可以參考下2023-12-12mybatis中association標(biāo)簽的使用解讀
這篇文章主要介紹了mybatis中association標(biāo)簽的使用,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-05-05