1、在pom.xml文件中增加assembly插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<executions>
<execution>
<id>pack_tar_gz</id>
<configuration>
<descriptor>assembly.xml</descriptor>
<fileName>???</fileName>
</configuration>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<execution>
</executions>
</configuration>
</plugin
2、在项目下创建assembly.xml文件,内容为
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> <id>jar-with-dependencies</id> <formats> <format>tar.gz</format> </formats> // <includeBaseDirectory>false</includeBaseDirectory> // <dependencySets> // <dependencySet> // <useProjectArtifact>true</useProjectArtifact> // <outputDirectory>/lib</outputDirectory> // <unpack>false</unpack> // <scope>runtime</scope> // </dependencySet> // </dependencySets> <fileSets> <fileSet> <directory>${project.build.outputDirectory}</directory> <outputDirectory>/</outputDirectory> </fileSet> </fileSets> </assembly>
3、打开maven Projects 点击install打包
4、查看target文件夹下有没有打包成功的xx-all.tar,gz文件