Pom
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>target/lib</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*.properties</exclude>
<exclude>**/*.xml</exclude>
<exclude>**/*.yml</exclude>
<exclude>admin/**</exclude>
<exclude>mapper/**</exclude>
<exclude>excel/**</exclude>
<exclude>excelXml/**</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
<includes>
<include>
<groupId>non-exists</groupId>
<artifactId>non-exists</artifactId>
</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>classes</classifier>
<attach>false</attach>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="dist">target/distribution</property>
<property name="dist-tmp">target/distribution/tmp</property>
<property name="app-name">${project.artifactId}-${project.version}</property>
<mkdir dir="${dist-tmp}" />
<copy file="target/${app-name}.jar" tofile="${dist-tmp}/${app-name}.jar" />
<unzip src="${dist-tmp}/${app-name}.jar" dest="${dist-tmp}" />
<delete file="${dist-tmp}/${app-name}.jar" />
<zip destfile="${dist}/${app-name}-pages.jar">
<zipfileset dir="${dist-tmp}/META-INF" prefix="META-INF" />
</zip>
<move file="target/${app-name}-classes.jar" todir="${dist}" />
<move todir="${dist}/3rd-lib">
<fileset dir="target/lib" />
</move>
<delete dir="${dist-tmp}" />
<copy todir="${dist}">
<fileset dir="target/classes">
<include name="**/*.properties" />
<include name="**/*.xml" />
<include name="**/*.yml" />
<include name="admin/**" />
<include name="mapper/**" />
<include name="excel/**" />
<include name="excelXml/**" />
</fileset>
</copy>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
主要通过
<configuration>
<excludes>
<exclude>**/*.properties</exclude>
<exclude>**/*.xml</exclude>
<exclude>**/*.yml</exclude>
<exclude>admin/**</exclude>
<exclude>mapper/**</exclude>
<exclude>excel/**</exclude>
<exclude>excelXml/**</exclude>
</excludes>
</configuration>
分离静态资源,
<copy todir="${dist}">
<fileset dir="target/classes">
<include name="**/*.properties" />
<include name="**/*.xml" />
<include name="**/*.yml" />
<include name="admin/**" />
<include name="mapper/**" />
<include name="excel/**" />
<include name="excelXml/**" />
</fileset>
</copy>
复制静态资源
启动命令:java -jar -Dloader.path=.,3rd-lib xxx-0.0.1-SNAPSHOT-classes.jar