激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

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

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

服務器之家 - 編程語言 - JAVA教程 - Spring boot 打jar包分離lib的正確配置方式

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

2021-04-07 13:33小祝特煩惱 JAVA教程

spring boot打jar包分離lib后,配置文件的方式,在網上可以搜到很多答案,但是都不夠完善,今天小編給大家帶來了Spring boot 打jar包分離lib的正確配置方式,感興趣的朋友一起看看吧

前言

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

部署環境

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

POM.xml

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?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>

打完包后目錄結構

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

運行jar

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

總結

以上所述是小編給大家介紹的Spring boot 打jar包分離lib的正確配置方式,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對服務器之家網站的支持!

原文鏈接:https://my.oschina.net/xiaozhutefannao/blog/1624092

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 一级黄色在线免费观看 | 中文字幕视频在线播放 | asian超清日本肉体pics | 牛牛碰在线 | 快播av在线 | 噜噜噜躁狠狠躁狠狠精品视频 | 成码无人av片在线观看网站 | 国产精品性夜天天视频 | 黄色大片免费网站 | 久久丝袜脚交足黄网站免费 | av免费大全 | 久久精品亚洲国产奇米99 | 亚洲精品成人18久久久久 | 久草视频在线资源 | 久久久成人动漫 | 久久精品视频3 | av免费在线观看免费 | 久色porn | 国产成人网 | 精品一区二区电影 | 欧美视频国产精品 | 欧美日韩国产一区二区三区在线观看 | 成人毛片免费播放 | 久久久久9999 | 日本成人在线免费 | 久久久久久免费 | 少妇淫片免费一级毛片 | 久久伊人精品视频 | 久久经典视频 | av免费在线播放网址 | 国产在线一区二区三区 | 美女91视频| 永久免费不卡在线观看黄网站 | 日韩精品一区二区三区中文 | 亚洲电影免费观看高清完整版在线观 | 最近中文字幕一区二区 | 久久欧美亚洲另类专区91大神 | 久久亚洲国产午夜精品理论片 | 国产欧美日韩在线播放 | 色精品国产 | 成人免费一区二区三区在线观看 |