如何在Maven中使用Maven中央仓库中的特定(非默认)jar包?(hive-exec)

huangapple go评论111阅读模式
英文:

How to use a specific (not default) jar from maven central repo with maven? (hive-exec)

问题

hive-exec模块恶意使用了一个fatjar来进行maven导入,导致出现了大量的类依赖错误,如guavaprotobufparquet等。我像这样导入它:

<dependency>
    <groupId>org.apache.hive</groupId>
    <artifactId>hive-exec</artifactId>
    <version>3.1.2</version>
</dependency>

但我在hive-exec的maven仓库中发现了一个名为hive-exec-3.1.2-core.jar的jar文件,它只包含自己的类!

是否有一种优雅的方法可以将这个jar文件作为我的Maven依赖导入,而不是默认的fatjar呢?

或者如果它无法访问,那么把那个jar放在那里的意义是什么?

附言:我知道在另一个模块中使用maven-shading可以解决我的问题,但是否实际上有一种方法可以在原地解决这个问题,而不需要创建另一个模块?

英文:

The hive-exec module evilly use a fatjar for maven import, which causes buckets of class dependency error like guava, protobuf, parquet, etc. I imported it like:

&lt;dependency&gt;
    &lt;groupId&gt;org.apache.hive&lt;/groupId&gt;
    &lt;artifactId&gt;hive-exec&lt;/artifactId&gt;
    &lt;version&gt;3.1.2&lt;/version&gt;
&lt;/dependency&gt;

But i found a jar named hive-exec-3.1.2-core.jar in hive-exec maven repo, which just contains its own classes!

Is there any elegant way to import this jar file with maven as my dependecy instead of the default fatjar?

Or if it's unreachable, literally what's the meaning of putting that jar there?

P.S. I know maven-shading it in another module can solve my problem, but is there actually a way to solve it in place without create another module.

答案1

得分: 2

你可以这样使用它:

<dependency>
    <groupId>org.apache.hive</groupId>
    <artifactId>hive-exec</artifactId>
    <classifier>core</classifier>
    <version>3.1.2</version>
</dependency>

这是否是一个合适的替代品,我无法确定。

英文:

You can use it in this way:

&lt;dependency&gt;
    &lt;groupId&gt;org.apache.hive&lt;/groupId&gt;
    &lt;artifactId&gt;hive-exec&lt;/artifactId&gt;
    &lt;classifier&gt;core&lt;/classifier&gt;
    &lt;version&gt;3.1.2&lt;/version&gt;
&lt;/dependency&gt;

whether this is a proper replacement, I cannot say.

huangapple
  • 本文由 发表于 2020年7月22日 17:21:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/63030951.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定