一、pom.xml文件里面的配置说明
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions> <!--执行器 mvn assembly:assembly-->
<execution>
<id>make-jar</id><!--名字任意 -->
<phase>package</phase><!-- 绑定到package生命周期阶段上 -->
<goals>
<goal>single</goal><!-- 只运行一次 -->
</goals>
<configuration>
<descriptors> <!--描述文件路径-->
<descriptor>src/main/assembly/jar.xml</descriptor>
</descriptors>
<outputDirectory><!--输出文件目录-->
${project.build.directory}
</outputDirectory>
<archive>
<manifest> <!--主main方法配置,需要执行可配置-->
<mainClass>com.xxx.xxx.Test</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
二、jar.xml配置
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>jar-release</id>
<!-- 打包格式 tar zip war zip-->
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<!--是否包含依赖包 -->
<dependencySets>
<dependencySet>
<unpack>true</unpack>
<scope>runtime</scope>
<outputDirectory>lib</outputDirectory><!--依赖包存储目录-->
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<!--想要打包的目录-->
<directory>${project.build.directory}/classes</directory>
<!--想要打包的内容-->
<includes>
<include>com/xxx/xxx/**</include>
<include>com/xxx/xxx/xxx/**</include>
<include>xxx.xml</include>
</includes>
<excludes><!--不想要打包的内容,可不要-->
<exclude>com/xxx/xxx</exclude>
</excludes>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>
三、执行 mvn:package