欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Spring boot 打jar包分離lib的正確配置方式

 更新時(shí)間:2018年02月27日 09:59:50   作者:小祝特?zé)? 
spring boot打jar包分離lib后,配置文件的方式,在網(wǎng)上可以搜到很多答案,但是都不夠完善,今天小編給大家?guī)砹薙pring boot 打jar包分離lib的正確配置方式,感興趣的朋友一起看看吧

前言

Springboot 打jar包分離lib,配置文件的方式,網(wǎng)上可以搜到的我都沒試通。跟劉大神(大神沒有博客,很可惜)討論后,給出了這么一個(gè)解決方案,供大家參考。

部署環(huán)境

  • window 10
  • redhat 6.4
  • 其他版本沒有嘗試,應(yīng)該也是可以的

POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<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.elvish</groupId>
  <artifactId>test</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>test</name>
  <description>test</description>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.10.RELEASE</version>
    <relativePath />
  </parent>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <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>target/lib</outputDirectory>
              <excludeTransitive>false</excludeTransitive>
              <stripVersion>false</stripVersion>
              <includeScope>runtime</includeScope>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/*.properties</exclude>
            <exclude>**/*.xml</exclude>
            <exclude>**/*.yml</exclude>
            <exclude>static/**</exclude>
            <exclude>templates/**</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <layout>ZIP</layout>
          <includes>
            <include>
              <groupId>non-exists</groupId>
              <artifactId>non-exists</artifactId>
            </include>
          </includes>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
            <configuration>
              <classifier>classes</classifier>
              <attach>false</attach>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <property name="dist">target/distribution</property>
                <property name="dist-tmp">target/distribution/tmp</property>
                <property name="app-name">${project.artifactId}-${project.version}</property>
                <mkdir dir="${dist-tmp}" />
                <copy file="target/${app-name}.jar" tofile="${dist-tmp}/${app-name}.jar" />
                <unzip src="${dist-tmp}/${app-name}.jar" dest="${dist-tmp}" />
                <delete file="${dist-tmp}/${app-name}.jar" />
                <zip destfile="${dist}/${app-name}-pages.jar">
                  <zipfileset dir="${dist-tmp}/META-INF" prefix="META-INF" />
                  <zipfileset dir="target/classes/static" prefix="static" />
                  <zipfileset dir="target/classes/templates" prefix="templates" />
                </zip>
                <move file="target/${app-name}-classes.jar" todir="${dist}" />
                <move todir="${dist}/3rd-lib">
                  <fileset dir="target/lib" />
                </move>
                <delete dir="${dist-tmp}" />
                <copy todir="${dist}">
                  <fileset dir="target/classes">
                    <include name="**/*.properties" />
                    <include name="**/*.xml" />
                    <include name="**/*.yml" />
                  </fileset>
                </copy>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

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

  • 3rd-lib
  • META-INF
  • *.yml
  • *.xml
  • *.properties
  • test-0.0.1-SNAPSHOT-classes.jar
  • test-0.0.1-SNAPSHOT-pages.jar

運(yùn)行jar

java -jar -Dloader.path=.,3rd-lib test-0.0.1-SNAPSHOT-classes.jar 

總結(jié)

以上所述是小編給大家介紹的Spring boot 打jar包分離lib的正確配置方式,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • spring security CSRF防護(hù)的示例代碼

    spring security CSRF防護(hù)的示例代碼

    這篇文章主要介紹了spring security CSRF防護(hù)的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2019-03-03
  • springboot 獲取工具類bean過程詳解

    springboot 獲取工具類bean過程詳解

    這篇文章主要介紹了springboot 獲取工具類bean過程詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-09-09
  • Java使用Ajax異步上傳文件

    Java使用Ajax異步上傳文件

    使用Ajax上傳文件的應(yīng)用場景頗多,比如上傳用戶頭像、博客文章中插入圖片、對(duì)認(rèn)證用戶相關(guān)身份進(jìn)行校驗(yàn)等等很多很多。本文提供一個(gè)簡單的示例供大家參考
    2021-05-05
  • Java開發(fā)中的容器概念、分類與用法深入詳解

    Java開發(fā)中的容器概念、分類與用法深入詳解

    這篇文章主要介紹了Java開發(fā)中的容器概念、分類與用法,結(jié)合實(shí)例形式較為詳細(xì)的分析了java容器的相關(guān)概念、分類、使用方法與注意事項(xiàng),需要的朋友可以參考下
    2017-11-11
  • Gradle構(gòu)建基本的Web項(xiàng)目結(jié)構(gòu)

    Gradle構(gòu)建基本的Web項(xiàng)目結(jié)構(gòu)

    這篇文章主要為大家介紹了Gradle創(chuàng)建Web項(xiàng)目基本的框架結(jié)構(gòu)搭建,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-03-03
  • ssm框架controller層返回json格式數(shù)據(jù)到頁面的實(shí)現(xiàn)

    ssm框架controller層返回json格式數(shù)據(jù)到頁面的實(shí)現(xiàn)

    這篇文章主要介紹了ssm框架controller層返回json格式數(shù)據(jù)到頁面的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • Mybatis-plus的selectPage()分頁查詢不生效問題解決

    Mybatis-plus的selectPage()分頁查詢不生效問題解決

    本文主要介紹了Mybatis-plus的selectPage()分頁查詢不生效問題解決,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-01-01
  • Java使用PrepareStatement實(shí)現(xiàn)數(shù)據(jù)的插入與查詢操作

    Java使用PrepareStatement實(shí)現(xiàn)數(shù)據(jù)的插入與查詢操作

    這篇文章主要為大家詳細(xì)介紹了Java如何使用PrepareStatement實(shí)現(xiàn)數(shù)據(jù)的插入與查詢操作,文中的示例代碼講解詳細(xì),感興趣的可以了解一下
    2022-09-09
  • SpringBoot靜態(tài)資源的訪問方法詳細(xì)介紹

    SpringBoot靜態(tài)資源的訪問方法詳細(xì)介紹

    最近在做SpringBoot項(xiàng)目的時(shí)候遇到了“白頁”問題,通過查資料對(duì)SpringBoot訪問靜態(tài)資源做了總結(jié),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧
    2022-09-09
  • BootStrap Jstree 樹形菜單的增刪改查的實(shí)現(xiàn)源碼

    BootStrap Jstree 樹形菜單的增刪改查的實(shí)現(xiàn)源碼

    這篇文章主要介紹了BootStrap Jstree 樹形菜單的增刪改查的實(shí)現(xiàn)源碼,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2017-02-02

最新評(píng)論