本文介绍了为什么用Maven Shade插件重定位不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到遇到一些麻烦,该任务正在运行包含以下内容的Hadoop作业:比Hadoop发行版(CDH 5.2)中包含的版本更新的Guava版本.这是一个已知的问题.我尝试通过使用Maven阴影插件对库进行着色来解决问题.因此,我在pom.xml中添加了以下几行:

I am having some trouble running a Hadoop job that includes a newer version of Guava than the one that is included in the Hadoop distribution (CDH 5.2). This is a known problem. I try to solve it by shading the libraries using the Maven shade plugin. Therefore, I added the following lines to my pom.xml:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.3</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <relocations>
            <relocation>
              <pattern>com.google</pattern>
              <shadedPattern>thirdparty.com.google</shadedPattern>
            </relocation>
          </relocations>
        </configuration>
      </execution>
    </executions>
  </plugin>

不幸的是,阴影似乎不起作用.提取uber-JAR时,没有文件夹thirdparty/com/google,但仍然是文件夹com/google.

Unfortunately, the shading seems not to work. When I extract the uber-JAR there is no folder thirdparty/com/google but still the folder com/google.

有人知道出了什么问题吗?

Does someone have an idea what is going wrong?

推荐答案

这对我有用:

<relocations>
   <relocation>
     <pattern>com.google.</pattern>
     <shadedPattern>thirdparty.com.google.</shadedPattern>
   </relocation>
 </relocations>

请注意图案结尾处的点.

note the dot at the end of the pattern.

这篇关于为什么用Maven Shade插件重定位不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!