2020年11月12日星期四

shade~实现打包多个关联包并过滤配置文件

使用maven-shade-plugin插件可以帮我们把多个依赖包打包一个jar包,并且在打包时可以帮我们过滤一些文件,比如每个依赖包里都有application.properties文件,在打包时这个文件会进行合并,这对于使用者来说是不希望的,它们更希望自己去写配置信息,所以在打包时,应该把配置文件过滤掉。

下面代码帮我们实现了关联包合并及过滤配置文件

<build>  <plugins>   <plugin>    <groupId>org.apache.maven.plugins</groupId>    <artifactId>maven-shade-plugin</artifactId>    <version>2.4.3</version>    <executions>     <execution>      <phase>package</phase>      <goals>       <goal>shade</goal>      </goals>      <configuration>       <!-- 过滤器排除配置文件-->       <filters>        <filter>         <artifact>*:*</artifact>         <excludes>          <exclude>**/*.properties</exclude>         </excludes>        </filter>       </filters>       <artifactSet>        <!-- 捆绑包含-->        <includes>         <include>com.lind:lind-common</include>         <include>com.lind:lind-limit-start</include>         <include>com.lind:lind-lock-start</include>        </includes>        <!-- 排除文件-->        <!-- <excludes>-->        <!-- </excludes>-->       </artifactSet>       <createSourcesJar>true</createSourcesJar>      </configuration>     </execution>    </executions>   </plugin>  </plugins> </build>

打完包之后,我们看到有源码jar和目标jar
1
我们任意打开一个jar,通过解压软件可以看到,里面的配置文件被过滤了
2

原文转载:http://www.shaoqun.com/a/489840.html

asiabill:https://www.ikjzd.com/w/1014

damai:https://www.ikjzd.com/w/1391

livingsocial:https://www.ikjzd.com/w/714.html


使用maven-shade-plugin插件可以帮我们把多个依赖包打包一个jar包,并且在打包时可以帮我们过滤一些文件,比如每个依赖包里都有application.properties文件,在打包时这个文件会进行合并,这对于使用者来说是不希望的,它们更希望自己去写配置信息,所以在打包时,应该把配置文件过滤掉。下面代码帮我们实现了关联包合并及过滤配置文件<build><plugin
转运四方:https://www.ikjzd.com/w/1342
c2c:https://www.ikjzd.com/w/1576
JUMIA卖家中心Seller Center功能介绍及操作详解:https://www.ikjzd.com/home/96553
广州南湖游乐园好玩吗?有什么好玩的?:http://tour.shaoqun.com/a/41989.html
普吉岛旅游实用小贴士 :http://tour.shaoqun.com/a/15771.html