一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

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

服務(wù)器之家 - 編程語言 - Java教程 - maven打包zip包含bin下啟動腳本的完整代碼

maven打包zip包含bin下啟動腳本的完整代碼

2022-03-03 00:49架構(gòu)藝術(shù) Java教程

這篇文章主要介紹了maven打包zip包含bin下啟動腳本,本文給大家講解的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

maven打包zip包含bin下啟動腳本,這個腳本小編在idea上測試有效:

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
<build>
        <sourceDirectory>src/main/scala</sourceDirectory>
        <testSourceDirectory>src/test/scala</testSourceDirectory>
 
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <!-- 排除外置的配置文件(運(yùn)行時注釋上,使IDE能讀到配置文件;打包時放開注釋讓配置文件外置,方便修改)可以不配置,maven-jar-plugin下面已配置 -->
                <!--<excludes>
                    <exclude>config.properties</exclude>
                </excludes>-->
            </resource>
            <!-- 配置文件外置的資源(存放到conf目錄,也是classpath路徑,下面會配置)-->
            <!--<resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>config.properties</include>
                </includes>
                <targetPath>${project.build.directory}/conf</targetPath>
            </resource>-->
        </resources>
 
        <plugins>
            <!--scala編譯打包插件-->
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
 
            <!--java編譯打包插件-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
 
            <!--
                ③打成一個zip包,發(fā)布項(xiàng)目的時候,將zip包c(diǎn)opy到服務(wù)器上,直接unzip xxx.zip,里面包含要運(yùn)行到的jar以及依賴的lib,還有配置的config文件,即可直接啟動服務(wù)
            -->
 
            <!--The configuration of maven-jar-plugin-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <!--The configuration of the plugin-->
                <configuration>
                    <!-- 不打包資源文件(配置文件和依賴包分開) -->
                    <excludes>
                        <exclude>*.properties</exclude>
                        <exclude>*.xml</exclude>
                        <exclude>*.txt</exclude>
                    </excludes>
                    <!--Configuration of the archiver-->
                    <archive>
                        <!--生成的jar中,不要包含pom.xml和pom.properties這兩個文件-->
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <!--Manifest specific configuration-->
                        <manifest>
                            <!--是否把第三方j(luò)ar放到manifest的classpath中-->
                            <addClasspath>true</addClasspath>
                            <!--生成的manifest中classpath的前綴,因?yàn)橐训谌絡(luò)ar放到lib目錄下,所以classpath的前綴是lib/-->
                            <classpathPrefix>lib/</classpathPrefix>
                            <!--應(yīng)用的main class-->
                            <mainClass>com.swordfall.restserver.base.WebServer</mainClass>
                        </manifest>
                        <!-- 給清單文件添加鍵值對,增加classpath路徑,這里將conf目錄也設(shè)置為classpath路徑 -->
                        <manifestEntries>
                            <Class-Path>conf/</Class-Path>
                        </manifestEntries>
                    </archive>
                    <!--過濾掉不希望包含在jar中的文件-->
                    <!-- <excludes>
                         <exclude>${project.basedir}/xml/*</exclude>
                     </excludes>-->
                </configuration>
            </plugin>
 
            <!--The configuration of maven-assembly-plugin-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4</version>
                <!--The configuration of the plugin-->
                <configuration>
                    <!--Specifies the configuration file of the assembly plugin-->
                    <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>

 assembly.xml打包zip設(shè)置

?
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
assembly.xml
 
<assembly>
    <id>bin</id>
    <includeBaseDirectory>false</includeBaseDirectory>
    <!-- 最終打包成一個用于發(fā)布的zip文件 -->
    <formats>
        <format>zip</format>
    </formats>
 
    <!-- Adds dependencies to zip package under lib directory -->
    <dependencySets>
        <dependencySet>
            <!-- 不使用項(xiàng)目的artifact,第三方j(luò)ar不要解壓,打包進(jìn)zip文件的lib目錄 -->
            <useProjectArtifact>false</useProjectArtifact>
            <outputDirectory>lib</outputDirectory>
            <unpack>false</unpack>
        </dependencySet>
    </dependencySets>
 
    <fileSets>
        <!-- 把項(xiàng)目相關(guān)的說明文件,打包進(jìn)zip文件的根目錄 -->
        <!--<fileSet>
            <directory>${project.basedir}</directory>
            <outputDirectory>/</outputDirectory>
        </fileSet>-->
 
        <!-- 把項(xiàng)目的配置文件,打包進(jìn)zip文件的config目錄 -->
        <!--<fileSet>-->
        <!--<directory>${project.basedir}/src/main/resources</directory>-->
        <!--<outputDirectory>/conf</outputDirectory>-->
        <!--<includes>-->
        <!--<include>*.xml</include>-->
        <!--<include>*.properties</include>-->
        <!--</includes>-->
        <!--</fileSet>-->
 
        <!-- 把項(xiàng)目自己編譯出來的jar文件,打包進(jìn)zip文件的根目錄 -->
        <fileSet>
            <directory>${project.build.directory}</directory>
            <outputDirectory></outputDirectory>
            <includes>
                <include>*.jar</include>
            </includes>
        </fileSet>
 
        <!-- 把項(xiàng)目的腳本文件目錄(src/main/scripts)中的啟動腳本,打包進(jìn)zip文件的根目錄 -->
        <fileSet>
            <directory>${project.basedir}/src/main/bin</directory>
            <outputDirectory>bin</outputDirectory>
            <includes>
                <include>*.sh</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

ps:下面看下maven 打zip包并包含bin和docs文件夾

maven插件:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<plugin>
 <artifactId>maven-assembly-plugin</artifactId>
 <configuration>
  <appendAssemblyId>false</appendAssemblyId>
  <descriptors>
   <descriptor>src/main/resources/assembly.xml</descriptor>
  </descriptors>
 </configuration>
 <executions>
  <execution>
   <id>make-assembly</id>
   <phase>package</phase>
   <goals>
    <goal>single</goal>
   </goals>
  </execution>
 </executions>
</plugin>

assembly.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
<assembly>
    <id>package</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>${project.parent.basedir}/bin</directory>
            <outputDirectory>\bin</outputDirectory>
        </fileSet>
        <fileSet>
            <directory>${project.parent.basedir}/db</directory>
            <outputDirectory>\db</outputDirectory>
        </fileSet>
        <fileSet>
            <directory>${project.parent.basedir}/docs</directory>
            <outputDirectory>\docs</outputDirectory>
        </fileSet>
        <fileSet>
            <directory>${project.parent.basedir}</directory>
            <outputDirectory>\</outputDirectory>
            <includes>
                <include>readme.md</include>
                <include>release-notes</include>
            </includes>
        </fileSet>
        <fileSet>
            <directory>${project.build.directory}</directory>
            <outputDirectory>\</outputDirectory>
            <includes>
                <include>*.jar</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>

到此這篇關(guān)于maven打包zip包含bin下啟動腳本的文章就介紹到這了,更多相關(guān)maven打包zip內(nèi)容請搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家!

原文鏈接:https://www.cnblogs.com/LIAOBO/p/15471400.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 2020国产精品永久在线观看 | 天天综合亚洲 | 香蕉精品视频 | 男人把大ji巴放进男人免费视频 | 国产网站视频 | 14一15sexvideo日本 | 91在线播 | 国产精品福利在线观看秒播 | 国产精品美女福利视频免费专区 | 青草青视频| 国产99精品免费视频看6 | 成人动漫影院 | 暖暖日本在线观看免费 | 亚洲国产天堂久久综合网站 | 香蕉久久综合 | 99久久综合精品免费 | 免费欧美一级片 | 毛片免费在线视频 | 精品久久免费视频 | 91赵邦贺| 国产嫩草视频 | 欧美色青 | 欧美免赞性视频 | 国产精品一区二区三 | 日韩经典在线观看 | 亚洲精品国产一区二区第一页 | 亚洲图片综合网 | 第一次不是你高清在线观看 | hd最新国产人妖ts视频 | 国内免费高清视频在线观看 | 亚洲欧美精品久久 | 亚洲成aⅴ人片在线 | 暖暖在线日本 | 日韩精品一区二区三区中文字幕 | 欧美日韩国产另类一区二区三区 | 日韩亚洲欧美一区二区三区 | yjsp妖精视频在线观看免费 | 国产一区二区三区在线观看视频 | 欧美日韩亚洲第一区在线 | 日韩欧美中文字幕一区 | 国产区1 |