国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - Java教程 - SpringCloud maven-assembly-plugin 多級目錄打包的實現

SpringCloud maven-assembly-plugin 多級目錄打包的實現

2022-03-02 00:58Mr-Wanter Java教程

本文主要介紹了SpringCloud maven-assembly-plugin 多級目錄打包的實現,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

1、spring-boot-maven-plugin

springboot默認打包工具為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>

打包后的目錄結構:

SpringCloud maven-assembly-plugin 多級目錄打包的實現

BOOT-INF內包含目錄: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 插件的主要作用是允許用戶將項目輸出與它的依賴項、模塊、站點文檔、和其他文件一起組裝成一個可分發的歸檔文件,簡單的說,就是自定義打包的工具,有自己的配置文件(Assembly描述符文件)。微服務使用這個插件的概率比較高,平時普通的項目不需要這樣的實現方式。

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

全部可設置節點可參考官網:http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html

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

  <includeBaseDirectory>true</includeBaseDirectory>
  <!--    項目所需lib包-->
  <!--    <dependencySets>-->
  <!--        &lt;!&ndash;把依賴都打包進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權限-->
          <fileMode>0755</fileMode>
      </fileSet>
      <!--打包可執行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>

打包后的目錄結構:

SpringCloud maven-assembly-plugin 多級目錄打包的實現

查看application-server文件夾內可執行文件解壓目錄:

SpringCloud maven-assembly-plugin 多級目錄打包的實現

發現與spring-boot-maven-plugin打包后的目錄不一致,明顯缺少lib內的三個jar和其他一些文件

 

3、maven-assembly-plugin打包后的可執行文件缺失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>
		<!-- 生成項目依賴到lib本地,并設置需要排除的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就會將其打包進enterprise-1.0.tar.gz。

這樣enterprise-1.0.tar.gz內就包含了啟動文件(deploy)、可執行文件(application-server/enterprise-main-1.0.0.jar)、日志目錄(logs/enterprise),符合目前項目部署的目錄結構。

SpringCloud maven-assembly-plugin 多級目錄打包的實現

到此這篇關于SpringCloud maven-assembly-plugin 多級目錄打包的實現的文章就介紹到這了,更多相關SpringCloud maven-assembly-plugin 多級目錄打包內容請搜索服務器之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持服務器之家!

原文鏈接:https://blog.csdn.net/mr_wanter/article/details/118697499

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 一区二区三区国产 | 黄免费| 精品国产污网站污在线观看15 | 精品中文字幕一区二区三区av | 亚洲综合自拍 | 国产一区影院 | 亚洲欧美一区二区三区国产精品 | 山岸逢花在线观看 | 女教师高潮叫床视频在线观看 | 男人的天堂在线视频 | 日本欧美久久久久免费播放网 | 精品二区 | 亚洲日本欧美日韩高观看 | 天天操天天干天天插 | 亚洲国产精品久久久久久6q | 黄色一区二区三区 | 欧美精品成人 | 中文字幕在线第一页 | 久久久成人精品 | www.国产 | 国产精品99久久久久久宅男 | 国产一级一级国产 | 亚洲欧美福利视频 | 精品国产乱码久久久久久丨区2区 | 亚洲欧美在线播放 | 国产一区二区在线免费观看 | 黄色a一级 | 午夜国产精品成人 | 久久精品亚洲成在人线av网址 | 精品一区二区久久 | 成人a视频在线观看 | 日韩精品一区二区在线 | 午夜激情视频在线观看 | 中文字幕亚洲一区二区三区 | 欧美激情一区二区 | 美女毛片| 伊人色私人影院蜜桃va | 成人美女av | 网站黄色在线观看免费 | 久久精品国产v日韩v亚洲 | 欧美日韩精品免费观看 |