assembly .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"> <formats> <format>zip</format> <!-- 设置打包后的格式为zip --> </formats> <fileSets> <!-- 要打包的文件 --> <fileSet> <!-- 根目录下的readme、license、notice文件 --> <directory>${project.basedir}</directory> <outputDirectory>/</outputDirectory> <includes> <include>README*</include> <include>LICENSE*</include> <include>NOTICE*</include> </includes> </fileSet> <fileSet><!-- bin目录下的所有文件(批处理文件) --> <directory>${project.basedir}/bin</directory> <outputDirectory>/</outputDirectory> </fileSet>
<fileSet><!-- target目录下的jar包 --> <directory>${project.build.directory}/</directory> <outputDirectory>/</outputDirectory> <includes> <include>*.jar</include> </includes> </fileSet> </fileSets> <dependencySets> <!-- 打包的依赖jar, 放置在lib下 --> <dependencySet> <outputDirectory>/lib</outputDirectory> <useProjectArtifact>false</useProjectArtifact> <scope>runtime</scope> </dependencySet> </dependencySets> </assembly>
Pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<artifactId>module-im</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>module-im</name>
<parent>
<groupId>com.shj</groupId>
<artifactId>micro-service-parent</artifactId>
<version>1.0.0</version>
</parent>
<properties>
<project.build.name>im</project.build.name>
</properties>
<dependencies>
<dependency>
<groupId>com.shj</groupId>
<artifactId>interface-im</artifactId>
<version>${ykee.version}</version>
</dependency>
</dependencies>
<build>
<finalName>module-im</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor><!-- 指定assembly配置文件路径 -->
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath><!-- 增加classpath -->
<classpathPrefix>lib/</classpathPrefix><!-- classpath路径前缀 -->
<mainClass>com.shj.ms.im.ImApplication</mainClass><!-- 程序主入口类 -->
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>