亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

maven如何打包zip包含bin下啟動腳本

發布時間:2021-10-31 09:42:58 來源:億速云 閱讀:540 作者:小新 欄目:開發技術

這篇文章主要為大家展示了“maven如何打包zip包含bin下啟動腳本”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“maven如何打包zip包含bin下啟動腳本”這篇文章吧。

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

pom.xml打包

<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>
                <!-- 排除外置的配置文件(運行時注釋上,使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包,發布項目的時候,將zip包copy到服務器上,直接unzip xxx.zip,里面包含要運行到的jar以及依賴的lib,還有配置的config文件,即可直接啟動服務
            -->

            <!--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>
                            <!--是否把第三方jar放到manifest的classpath中-->
                            <addClasspath>true</addClasspath>
                            <!--生成的manifest中classpath的前綴,因為要把第三方jar放到lib目錄下,所以classpath的前綴是lib/-->
                            <classpathPrefix>lib/</classpathPrefix>
                            <!--應用的main class-->
                            <mainClass>com.swordfall.restserver.base.WebServer</mainClass>
                        </manifest>
                        <!-- 給清單文件添加鍵值對,增加classpath路徑,這里將conf目錄也設置為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設置

assembly.xml

<assembly>
    <id>bin</id>
    <includeBaseDirectory>false</includeBaseDirectory>
    <!-- 最終打包成一個用于發布的zip文件 -->
    <formats>
        <format>zip</format>
    </formats>

    <!-- Adds dependencies to zip package under lib directory -->
    <dependencySets>
        <dependencySet>
            <!-- 不使用項目的artifact,第三方jar不要解壓,打包進zip文件的lib目錄 -->
            <useProjectArtifact>false</useProjectArtifact>
            <outputDirectory>lib</outputDirectory>
            <unpack>false</unpack>
        </dependencySet>
    </dependencySets>

    <fileSets>
        <!-- 把項目相關的說明文件,打包進zip文件的根目錄 -->
        <!--<fileSet>
            <directory>${project.basedir}</directory>
            <outputDirectory>/</outputDirectory>
        </fileSet>-->

        <!-- 把項目的配置文件,打包進zip文件的config目錄 -->
        <!--<fileSet>-->
        <!--<directory>${project.basedir}/src/main/resources</directory>-->
        <!--<outputDirectory>/conf</outputDirectory>-->
        <!--<includes>-->
        <!--<include>*.xml</include>-->
        <!--<include>*.properties</include>-->
        <!--</includes>-->
        <!--</fileSet>-->

        <!-- 把項目自己編譯出來的jar文件,打包進zip文件的根目錄 -->
        <fileSet>
            <directory>${project.build.directory}</directory>
            <outputDirectory></outputDirectory>
            <includes>
                <include>*.jar</include>
            </includes>
        </fileSet>

        <!-- 把項目的腳本文件目錄(src/main/scripts)中的啟動腳本,打包進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插件:

<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

<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>

以上是“maven如何打包zip包含bin下啟動腳本”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

台中县| 瓦房店市| 芜湖县| 乳源| 丽江市| 威信县| 南昌县| 英山县| 浠水县| 巢湖市| 平罗县| 丽江市| 柳河县| 中宁县| 孟津县| 两当县| 长兴县| 华坪县| 山阳县| 天气| 西青区| 鄢陵县| 晋城| 宁国市| 墨江| 共和县| 博乐市| 天台县| 牡丹江市| 塔河县| 兴隆县| 博客| 托克逊县| 凤山县| 郓城县| 兴化市| 凌源市| 和田县| 红河县| 滕州市| 乌什县|