account的target目录下会达成2个包
account-$version.SNAPSHOT.jar 和 account.tar.gz
account-$version.SNAPSHOT.jar只包含自己的class,没有依赖包(mvn-parent打出来的所有包,都没有依赖包)
最终结果会达成一个account.tar.gz包
解压之后的目录
目录分析
bin
这里存放的是启动脚本
conf
这里存放的是配置文件
libs
mvn-parent所依赖的所有第3方包
services
account所依赖的module,包括自己
这里面打出来的,都没有依赖包的
启动
点击startup脚本启动
maven-assembly-plugin插件配置
pom.xml
<build>
<plugins>
<!-- 只要自己class打包,不要用spring-boot-maven-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.kq.mvn.acccount.AccountApplication</mainClass>
</manifest>
</archive>
<excludes>
<exclude>*.yml</exclude>
<exclude>*.bat</exclude>
<exclude>*.vmoptions</exclude>
<exclude>scripts/</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>${artifactId}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/resources/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
<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
http://maven.apache.org/ASSEMBLY/2.0.0 ">
<id>assembly</id>
<baseDirectory>account</baseDirectory>
<formats>
<format>tar.gz</format>
<!--<format>dir</format>-->
</formats>
<dependencySets>
<dependencySet>
<excludes>
<exclude>com.kq.*:*</exclude>
</excludes>
<outputDirectory>/libs</outputDirectory>
</dependencySet>
<dependencySet>
<includes>
<include>com.kq.*:*</include>
</includes>
<outputDirectory>/services</outputDirectory>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>src/main/resources/scripts</directory>
<outputDirectory>/bin</outputDirectory>
<includes>
<include>*.bat</include>
<include>*.xml</include>
<include>*.sh</include>
<include>*.exe</include>
<include>*.vmoptions</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>src/main/resources</directory>
<outputDirectory>/conf</outputDirectory>
<includes>
<include>*.yml</include>
</includes>
<fileMode>0644</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>README</source>
<outputDirectory>/</outputDirectory>
</file>
</files>
</assembly>
参考资料
http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html