亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Springboot基于maven打包分離lib及resource

 更新時(shí)間:2020年10月15日 10:25:01   作者:賈小仙  
這篇文章主要介紹了Springboot基于maven打包分離lib及resource,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

之前在部署Spring Boot項(xiàng)目時(shí),經(jīng)常因?yàn)橹恍薷牧艘恍√幋a、或者只更新了某個(gè)jar包,但是卻需要將整個(gè)項(xiàng)目重新打包、上傳、部署,整個(gè)包一般都會(huì)達(dá)到40-60M,每次都重復(fù)這個(gè)操作真的很耗費(fèi)時(shí)間,因此就想是否能夠?qū)⒁蕾噇ib與項(xiàng)目代碼分離出來(lái),每次部署只需要發(fā)布代碼即可。

項(xiàng)目發(fā)版,為了應(yīng)對(duì)更新多變的依賴jar包,實(shí)現(xiàn)增量或替換依賴jar包,越來(lái)越多的企業(yè)實(shí)現(xiàn)源代碼和依賴jar包和依賴配置分離,更好的應(yīng)對(duì)復(fù)雜多變的現(xiàn)場(chǎng)和生產(chǎn)環(huán)境,使用maven打包配置如下:

<build>
<plugins>
 <!-- 指定啟動(dòng)類,將依賴打成外部jar包 -->
 <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <configuration>
   <archive>
    <!-- 生成的jar中,不要包含pom.xml和pom.properties這兩個(gè)文件 -->
    <addMavenDescriptor>false</addMavenDescriptor>
    <manifest>
     <!-- 是否要把第三方j(luò)ar加入到類構(gòu)建路徑 -->
     <addClasspath>true</addClasspath>
     <!-- 外部依賴jar包的最終位置 -->
     <classpathPrefix>lib/</classpathPrefix>
     <!-- 項(xiàng)目啟動(dòng)類 -->
     <mainClass>com.mozi.mq_monitor.MqMonitorApplication</mainClass>
    </manifest>
   </archive>
  </configuration>
 </plugin>
 <!--拷貝依賴到j(luò)ar外面的lib目錄-->
 <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
   <execution>
    <id>copy-lib</id>
    <phase>package</phase>
    <goals>
     <goal>copy-dependencies</goal>
    </goals>
    <configuration>
     <outputDirectory>target/lib</outputDirectory>
     <excludeTransitive>false</excludeTransitive>
     <stripVersion>false</stripVersion>
     <includeScope>compile</includeScope>
    </configuration>
   </execution>
  </executions>
 </plugin>
 <!--指定配置文件,將resources打成外部resource-->
 <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <configuration>
   <archive>
    <!-- 指定配置文件目錄,這樣jar運(yùn)行時(shí)會(huì)去找到同目錄下的resources文件夾下查找 -->
    <manifestEntries>
     <Class-Path>resources/</Class-Path>
    </manifestEntries>
   </archive>
   <!-- 打包時(shí)忽略的文件(也就是不打進(jìn)jar包里的文件) -->
   <excludes>
    <exclude>*.yml</exclude>
    <exclude>*.xml</exclude>
    <exclude>mqConfig/*.xml</exclude>
   </excludes>
  </configuration>
 </plugin>
 <!-- 拷貝資源文件 外面的resource目錄-->
 <plugin>
  <artifactId>maven-resources-plugin</artifactId>
  <executions>
   <execution>
    <id>copy-dependencies</id>
    <phase>package</phase>
    <goals>
     <goal>copy-resources</goal>
    </goals>
    <configuration>
     <!-- 資源文件輸出目錄 -->
     <outputDirectory>${project.build.directory}/resources</outputDirectory>
     <resources>
      <resource>
       <directory>src/main/resources</directory>
      </resource>
     </resources>
    </configuration>
   </execution>
  </executions>
 </plugin>
</plugins>
</build>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論