Maven Shade插件配置未替换软件包 [英] Maven shade plugin configuration not replacing the package
本文介绍了Maven Shade插件配置未替换软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基于 Maven依赖项不兼容的库类的要求,我尝试了如下所示的shade插件,但徒劳无功.
Based on the requirement at Maven dependency incompatible library class, I have tried shade plugin as like below, but went in vain.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>com.lib:Encoder</artifact>
<includes>
<include>x/y/z/**</include>
</includes>
<excludes>
<exclude>a/b/c/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
我的目标是用x.y.z类替换a.b.c结构的包. 我在这里错过任何重要的配置吗?
My target here is to replace the package with of a.b.c structure with x.y.z of classes. Did I miss any crucial configurations here?
推荐答案
要将着色包中的 abc 包替换为 xyz ,您应该添加重定位如下,在maven-shade-plugin上输入:
To replace the package a.b.c with x.y.z on your shaded jar you should add the relocations entry as follow on maven-shade-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<relocations>
<relocation>
<pattern>x.y.z</pattern>
<shadedPattern>a.b.c</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
这篇关于Maven Shade插件配置未替换软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文