【问题标题】:Maven hive-exec conflicts with protobufMaven hive-exec 与 protobuf 冲突
【发布时间】: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 应该是相关的。

我的问题是:

  1. 如何排除内置的 protobuff,并使用 protobuff 3.1.0 覆盖该类?在这种情况下,普通的&lt;excludes&gt; 似乎不起作用。

  2. 如果我无法覆盖它,如何找到 protobuff 类的版本?我在 hive-exec.pom 中找不到它。

非常感谢!!

【问题讨论】:

标签: maven hive protocol-buffers


【解决方案1】:

hive-exec 也有这个 .jar 的核心分类器。下面是我在 Gradle 中解决这个问题的方法,Maven 提供了一个 &lt;classifier&gt; 标签,你应该可以使用。

implementation group: 'org.apache.hive', name: 'hive-exec', version: '3.1.2', classifier: 'core'

这个版本在他们愚蠢的非阴影 .jar 中没有其他依赖项来弄乱你的类路径,当我遇到类似问题时它为我解决了问题。

【讨论】:

  • 它对我有用,classifier: 'core' 是什么意思?
【解决方案2】:

将 protobuf-java 放在 hive-exec 之前对我有用:

<!-- protobuf-java should come before hive-exec -->
<dependency>
  <groupId>com.google.protobuf</groupId>
  <artifactId>protobuf-java</artifactId>
  <version>3.6.0</version>
</dependency>
<dependency>
  <groupId>org.apache.hive</groupId>
  <artifactId>hive-exec</artifactId>
  <version>3.1.2</version>
</dependency>

【讨论】:

    猜你喜欢
    • 2018-01-24
    • 1970-01-01
    • 1970-01-01
    • 2015-06-18
    • 2018-04-05
    • 2016-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多