【发布时间】:2021-07-23 15:19:14
【问题描述】:
我是 maven 的新手。在我的项目中,我发现 hive-exec 与 protobuf 冲突。下面是我项目中的pom。
<dependencies>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>0.13.0.2.1.7.0-784</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<scope>compile</scope>
<version>3.1.0</version>
</dependency>
</dependencies>
所以我更深入地研究了hive-exec。我发现它使用的是 maven-shade-plugin。我猜它是用来打包 hive-exec jar 的。下面是hive-exec.pom中的相关代码:
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>build-exec-bundle</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
...
<include>com.google.protobuf:protobuf-java</include>
...
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.esotericsoftware</pattern>
<shadedPattern>org.apache.hive.com.esotericsoftware</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
还有(我不确定配置文件是如何工作的):
<profile>
<id>protobuf</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-protobuf-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property />
<property />
<echo>Building ORC Protobuf</echo>
<mkdir />
<exec>
<arg />
<arg />
<arg />
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
这里有一个JIRA 应该是相关的。
我的问题是:
如何排除内置的 protobuff,并使用 protobuff 3.1.0 覆盖该类?在这种情况下,普通的
<excludes>似乎不起作用。如果我无法覆盖它,如何找到 protobuff 类的版本?我在 hive-exec.pom 中找不到它。
非常感谢!!
【问题讨论】:
-
将 proto-buff 依赖项放在 hive-exec 前面解决了冲突!感谢stackoverflow.com/questions/30770549/…。我仍然对其他解决方案持开放态度。
标签: maven hive protocol-buffers