如何把依赖的jar包中的资源抽到当前jar中
maven-compiler-plugin:编译插件,可指定资源jdk版本,前提是当前代码使用的jdk版本 大于或等于 source
maven-assembly-plugin:组装插件,这个插件功能很多,可以直接生成可执行jar,这里仅用来抽取依赖jar中的资源到当前jar包 (jar-with-dependencies)
maven-shade-plugin:配合maven-assembly-plugin插件jar-with-dependencies情况,可过滤依赖jar包及资源,如我只要其中几个jar包,可使用includes,不要的jar包可excludes,还可以exclude打包后的部分目录,如maven的配置
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<!-- NOTE: We don't need a groupId specification because the group is
org.apache.maven.plugins ...which is assumed by default. -->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!--<descriptors>-->
<!--<descriptor>/assembly/assembly.xml</descriptor>-->
<!--</descriptors>-->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<!--<minimizeJar>true</minimizeJar>-->
<artifactSet>
<includes>
<include>com.jd.xx:xx-model</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
</filters>
<!--<filters>-->
<!--<filter>-->
<!--<artifact>com.jd.xx:xx-model</artifact>-->
<!--<includes>-->
<!--<include>com/jd/xx/model</include>-->
<!--</includes>-->
<!--</filter>-->
<!--</filters>-->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>