Rob*_*ert 8 java hadoop maven guava maven-shade-plugin
我在运行包含较新版本的Guava的Hadoop作业时遇到了一些麻烦,而不是Hadoop发行版(CDH 5.2)中包含的版本.这是一个已知问题.我尝试通过使用Maven shade插件对库进行着色来解决它.因此,我在以下行中添加了以下内容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>
Run Code Online (Sandbox Code Playgroud)
不幸的是,阴影似乎不起作用.当我提取uber-JAR时,没有文件夹,thirdparty/com/google但仍然是文件夹com/google.
有人知道出了什么问题吗?
这对我有用:
<relocations>
<relocation>
<pattern>com.google.</pattern>
<shadedPattern>thirdparty.com.google.</shadedPattern>
</relocation>
</relocations>
Run Code Online (Sandbox Code Playgroud)
注意图案末尾的点。
您可能需要在您的<configuration>部分下指定显式的artifactSet::includes:
<configuration>
<artifactSet>
<includes>
<include>com.google.guava:*</include>
...
</includes>
</artifactSet>
<relocations>
...
Run Code Online (Sandbox Code Playgroud)