最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringCloud maven-assembly-plugin 多級目錄打包的實(shí)現(xiàn)

 更新時間:2021年10月27日 10:48:29   作者:Mr-Wanter  
本文主要介紹了SpringCloud maven-assembly-plugin 多級目錄打包的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

1、spring-boot-maven-plugin

springboot默認(rèn)打包工具為spring-boot-maven-plugin

pom配置:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <mainClass>com.gsafety.bg.enterprise.EnterpriseApplication</mainClass>
        <layout>ZIP</layout>
        <!-- 打增量包時需要includes部分, 要打全量包刪除includes -->
        <includes>
            <include>
                <groupId>com.gsafety.bg</groupId>
                <artifactId>enterprise-controller</artifactId>
            </include>
            <include>
                <groupId>com.gsafety.bg</groupId>
                <artifactId>enterprise-service</artifactId>
            </include>
            <include>
                <groupId>com.gsafety.bg</groupId>
                <artifactId>enterprise-dao</artifactId>
            </include>
        </includes>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

打包后的目錄結(jié)構(gòu):

在這里插入圖片描述

BOOT-INF內(nèi)包含目錄:lib(enterprise-service-1.0.0.jar、enterprise-dao-1.0.0.jar、enterprise-controller-1.0.0.jar)、classes、classpath.idx

2、maven-assembly-plugin

maven-assembly-plugin 插件的主要作用是允許用戶將項(xiàng)目輸出與它的依賴項(xiàng)、模塊、站點(diǎn)文檔、和其他文件一起組裝成一個可分發(fā)的歸檔文件,簡單的說,就是自定義打包的工具,有自己的配置文件(Assembly描述符文件)。微服務(wù)使用這個插件的概率比較高,平時普通的項(xiàng)目不需要這樣的實(shí)現(xiàn)方式。

pom配置:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.4.1</version>
    <configuration>
        <finalName>enterprise</finalName>
        <encoding>utf-8</encoding>
        <descriptors>
            <descriptor>src/main/assembly/assembly.xml</descriptor>
        </descriptors>
    </configuration>
    <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

assembly.xml

全部可設(shè)置節(jié)點(diǎn)可參考官網(wǎng):http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html

<assembly>
    <id>1.0</id>
    <formats>
        <format>tar.gz</format>
    </formats>

    <includeBaseDirectory>true</includeBaseDirectory>
    <!--    項(xiàng)目所需lib包-->
    <!--    <dependencySets>-->
    <!--        &lt;!&ndash;把依賴都打包進(jìn)libs文件夾&ndash;&gt;-->
    <!--        <dependencySet>-->
    <!--            <useProjectArtifact>true</useProjectArtifact>-->
    <!--            <outputDirectory>libs</outputDirectory>-->
    <!--            <scope>runtime</scope>-->
    <!--        </dependencySet>-->
    <!--    </dependencySets>-->
    <fileSets>
        <!--打包啟動文件到deploy目錄-->
        <fileSet>
            <!--需要打包的文件所在目錄 即start.sh-->
            <directory>src/main/assembly/bin</directory>
            <!--要打包到的地址-->
            <outputDirectory>deploy</outputDirectory>
            <!--linux權(quán)限-->
            <fileMode>0755</fileMode>
        </fileSet>
        <!--打包可執(zhí)行jar到application-server目錄-->
        <fileSet>
            <directory>target</directory>
            <outputDirectory>application-server</outputDirectory>
            <includes>
                <include>*.jar</include>
            </includes>
        </fileSet>
        <!--打包src/main/resources到logs/enterprise目錄-->
        <fileSet>
            <directory>src/main/resources</directory>
            <outputDirectory>logs/enterprise</outputDirectory>
            <fileMode>0755</fileMode>
            <!--打包不包含src/main/resources所有文件,即生成logs/enterprise空目錄-->
            <excludes>
                <exclude>**/*</exclude>
            </excludes>
        </fileSet>
    </fileSets>
</assembly>

打包后的目錄結(jié)構(gòu):

在這里插入圖片描述

查看application-server文件夾內(nèi)可執(zhí)行文件解壓目錄:

在這里插入圖片描述

發(fā)現(xiàn)與spring-boot-maven-plugin打包后的目錄不一致,明顯缺少lib內(nèi)的三個jar和其他一些文件

3、maven-assembly-plugin打包后的可執(zhí)行文件缺失lib問題

修改pom文件:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <mainClass>com.gsafety.bg.enterprise.EnterpriseApplication</mainClass>
                <layout>ZIP</layout>
                <!-- 打增量包時需要includes部分, 要打全量包刪除includes -->
                <includes>
                    <include>
                        <groupId>com.gsafety.bg</groupId>
                        <artifactId>enterprise-controller</artifactId>
                    </include>
                    <include>
                        <groupId>com.gsafety.bg</groupId>
                        <artifactId>enterprise-service</artifactId>
                    </include>
                    <include>
                        <groupId>com.gsafety.bg</groupId>
                        <artifactId>enterprise-dao</artifactId>
                    </include>
                </includes>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
		<!-- 生成項(xiàng)目依賴到lib本地,并設(shè)置需要排除的jar-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>../../../lib</outputDirectory>
                        <!-- 需要排除的jar的 groupId -->
                        <excludeArtifactIds>
                            enterprise-controller,enterprise-service,enterprise-dao
                        </excludeArtifactIds>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4.1</version>
            <configuration>
                <finalName>enterprise</finalName>
                <encoding>utf-8</encoding>
                <descriptors>
                    <descriptor>src/main/assembly/assembly.xml</descriptor>
                </descriptors>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

即plugins先引用spring-boot-maven-plugin 后引用maven-assembly-plugin,這樣spring-boot-maven-plugin會將enterprise-service-1.0.0.jar、enterprise-dao-1.0.0.jar、enterprise-controller-1.0.0.jar三個jar打包到lib中,打包后maven-assembly-plugin就會將其打包進(jìn)enterprise-1.0.tar.gz。

這樣enterprise-1.0.tar.gz內(nèi)就包含了啟動文件(deploy)、可執(zhí)行文件(application-server/enterprise-main-1.0.0.jar)、日志目錄(logs/enterprise),符合目前項(xiàng)目部署的目錄結(jié)構(gòu)。

在這里插入圖片描述

到此這篇關(guān)于SpringCloud maven-assembly-plugin 多級目錄打包的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)SpringCloud maven-assembly-plugin 多級目錄打包內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Java深入淺出數(shù)組的定義與使用上篇

    Java深入淺出數(shù)組的定義與使用上篇

    數(shù)組是有序的元素序列,若將有限個類型相同的變量的集合命名,那么這個名稱為數(shù)組名。組成數(shù)組的各個變量稱為數(shù)組的分量,也稱為數(shù)組的元素,有時也稱為下標(biāo)變量。數(shù)組是在程序設(shè)計(jì)中,為了處理方便, 把具有相同類型的若干元素按有序的形式組織起來的一種形式
    2022-03-03
  • 使用Java注解模擬spring ioc容器過程解析

    使用Java注解模擬spring ioc容器過程解析

    這篇文章主要介紹了使用Java注解模擬spring ioc容器過程解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-07-07
  • springboot根據(jù)sessionId查詢session方式

    springboot根據(jù)sessionId查詢session方式

    文章介紹了通過保存session和sessionId進(jìn)行跨域問題的校驗(yàn),提出創(chuàng)建保存session的類,建立監(jiān)聽器監(jiān)聽session的創(chuàng)建和銷毀,并在啟動類上添加注解@ServletComponentScan以掃描SessionListener
    2026-04-04
  • java實(shí)現(xiàn)數(shù)據(jù)庫的數(shù)據(jù)寫入到txt的方法

    java實(shí)現(xiàn)數(shù)據(jù)庫的數(shù)據(jù)寫入到txt的方法

    這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)數(shù)據(jù)庫的數(shù)據(jù)寫入到txt的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-07-07
  • java實(shí)現(xiàn)單機(jī)版五子棋小游戲

    java實(shí)現(xiàn)單機(jī)版五子棋小游戲

    這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)單機(jī)版五子棋小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-12-12
  • Java中字符串替換的四種方法舉例總結(jié)

    Java中字符串替換的四種方法舉例總結(jié)

    Java提供了多種方法來替換字符串,其中最常用的是使用replace()方法和正則表達(dá)式,下面這篇文章主要給大家介紹了關(guān)于Java中字符串替換的四種方法,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-08-08
  • Java中常見HTTP 400錯誤的原因和正確處理方法

    Java中常見HTTP 400錯誤的原因和正確處理方法

    HTTP 400 Bad Request是客戶端錯誤的一種,表示服務(wù)器無法理解或處理客戶端發(fā)送的請求,錯誤原因通常在于客戶端請求中存在語法錯誤、格式不正確或參數(shù)不符合預(yù)期,所以本文給大家介紹了Java中常見HTTP 400錯誤的原因和正確處理方法,需要的朋友可以參考下
    2025-11-11
  • java 獲取中文拼音首字母及全拼的實(shí)踐

    java 獲取中文拼音首字母及全拼的實(shí)踐

    本文主要介紹了java 獲取中文拼音首字母及全拼的實(shí)踐,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08
  • SpringBoot配置MyBatis-Plus實(shí)現(xiàn)增刪查改

    SpringBoot配置MyBatis-Plus實(shí)現(xiàn)增刪查改

    本文主要介紹了SpringBoot配置MyBatis-Plus實(shí)現(xiàn)增刪查改,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • Java使用Maven BOM統(tǒng)一管理版本號的實(shí)現(xiàn)

    Java使用Maven BOM統(tǒng)一管理版本號的實(shí)現(xiàn)

    這篇文章主要介紹了Java使用Maven BOM統(tǒng)一管理版本號的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-04-04

最新評論

上蔡县| 阜新市| 墨江| 河曲县| 波密县| 商河县| 应用必备| 嘉义县| 株洲市| 闽清县| 关岭| 临清市| 揭东县| 景东| 曲麻莱县| 晋江市| 南昌市| 莒南县| 汝州市| 邵东县| 自贡市| 开江县| 郑州市| 沙河市| 疏勒县| 鄂州市| 聂拉木县| 托克逊县| 贡山| 大足县| 荃湾区| 日土县| 武汉市| 邛崃市| 赫章县| 安阳县| 博客| 贡嘎县| 瑞金市| 林周县| 多伦县|