springboot項目打zip包之打包插件assembly

maven配置打包插件assembly,一般打這個包是要配置自動化部署jenkins等工具需要。

pom.xml

<plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <finalName>fastboot</finalName>
                    <descriptors>
                        <descriptor>src/assembly/assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id> <!-- this is used for inheritance merges -->
                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

上面標籤解釋一下你需要改的兩個,finalName是生成文件名的 A-B.zip的A,descriptor裏面是讀取下面具體配置的,配置文件路徑

assembly.xml

<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
    <id>app</id>
    <formats>
        <format>zip</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>bin</directory>
            <outputDirectory>bin</outputDirectory>
        </fileSet>
    </fileSets>
    <files>
        <file>
            <source>target/fastboot.jar</source>
            <outputDirectory>/lib</outputDirectory>
        </file>
    </files>
</assembly>

上面標籤解釋一下你需要改的兩個,id是生成文件名的 A-B.zip的B,format是A-B.zip的zip後綴,可以改成別的。 filesets是把directory的文件複製到outputDirectory下面,file是把source的具體jar移動到outputDirectory下面。

文件名:最後生成的文件名是,pom.xml的finalName,然後橫槓-,assembly.xml的id,然後以assembly.xml裏面的format作爲文件後綴,以這裏爲例就是fastboot-app.zip

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章