詳解Spring Boot 打包分離依賴JAR 和配置文件
1:自定義路徑
<properties> <!--自定義路徑--> <directory>d:/im/</directory> </properties>
2:把配置文件打包出來
<build> <plugins> <!--上線部署 JAR啟動分離依賴lib和配置--> <!--打包jar--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <!--不打包資源文件--> <excludes> <exclude>*.**</exclude> </excludes> <archive> <manifest> <addClasspath>true</addClasspath> <!--MANIFEST.MF 中 Class-Path 加入前綴--> <classpathPrefix>lib/</classpathPrefix> <!--jar包不包含唯一版本標(biāo)識--> <useUniqueVersions>false</useUniqueVersions> <!--指定入口類--> <mainClass>com.v.im.VServerApplication</mainClass> </manifest> <!-- 指定配置文件目錄,這樣jar運行時會去找到同目錄下的config文件夾下查找 --> <manifestEntries> <Class-Path>config/</Class-Path> </manifestEntries> </archive> <outputDirectory>${directory}</outputDirectory> </configuration> </plugin> <!--拷貝依賴 copy-dependencies--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory> ${directory}/lib/ </outputDirectory> </configuration> </execution> </executions> </plugin> <!--拷貝資源文件 copy-resources--> <plugin> <artifactId>maven-resources-plugin</artifactId> <executions> <execution> <id>copy-resources</id> <phase>package</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <resources> <resource> <directory>src/main/resources</directory> <!-- 指定參與構(gòu)建的resoures--> <includes> <include>*.**</include> </includes> </resource> </resources> <outputDirectory>${directory}/config</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> </build>
3:打包文件截圖
到此這篇關(guān)于詳解Spring Boot 打包分離依賴JAR 和配置文件的文章就介紹到這了,更多相關(guān)Spring Boot 打包依賴內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
IDEA2020.2.3 "reading maven projects"卡住的問題
這篇文章主要介紹了IDEA2020.2.3 "reading maven projects"卡住的問題及問題原因探究,通過多種方法給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2020-10-10Sleuth(Micrometer)+ZipKin分布式鏈路問題小結(jié)
在微服務(wù)架構(gòu)中,分布式鏈路追蹤技術(shù)成為了解決系統(tǒng)復(fù)雜調(diào)用問題的關(guān)鍵,本文介紹了其他鏈路追蹤方案,如Cat、Pinpoint和Skywalking,展示了分布式鏈路追蹤技術(shù)的多樣化,感興趣的朋友一起看看吧2024-10-10Java如何使用ConfigurationProperties獲取yml中的配置
這篇文章主要介紹了Java如何使用ConfigurationProperties獲取yml中的配置,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-02-02Java深入學(xué)習(xí)圖形用戶界面GUI之創(chuàng)建窗體
圖形編程中,窗口是一個重要的概念,窗口其實是一個矩形框,應(yīng)用程序可以使用其從而達到輸出結(jié)果和接受用戶輸入的效果,學(xué)習(xí)了GUI就讓我們用它來創(chuàng)建一個窗體2022-05-05intelliJ idea 2023 配置Tomcat 8圖文教程
這篇文章主要介紹了intelliJ idea 2023 配置Tomcat 8教程,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-06-06IDEA手動添加junit4時出現(xiàn)的問題與解決方法
這篇文章主要給大家介紹了關(guān)于IDEA手動添加junit4時出現(xiàn)的問題與解決方法,文中通過圖文介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03