如何在Java项目中使用被省略的库

huangapple 未分类评论49阅读模式
英文:

How to use ommited library in java project

问题

我在项目中有两个作为依赖的库。这两个库中每个都有许多其他库作为依赖。然而,有两个同名但版本不同的库,并且其中一个在Maven的POM依赖层次结构中被省略了,与同名的另一个库产生了冲突。当我运行程序时,它使用了两个“父”库的元素,但它使用了一个冲突的“子”库,它试图与应该使用另一个冲突库的“父”库一起工作。所以在项目中是否有可能同时使用这两个冲突的库。

谢谢

英文:

I have two libraries as dependencies in my project. Each of those two libraries has bunch of libraries as dependency. However there are two same named libraries with different version, and one of them as I can see in maven pom dependency hierarchy is ommited conflicting with same named one. When I run program program it uses elements of both "parent" libs, but it uses one of conflicting "child" libs whit which it tries to work with "parent" lib which should use other conflicting lib. So is it possible to have both conflicting libs used in project.

Thanks

答案1

得分: 0

并不完全如此。

您可以使用Maven Shade插件创建一个带有不同包层次结构的依赖项的阴影jar包。

但通常的解决方案是尝试找到一个与所有其他内容兼容的库版本(并不总是可能的,我知道)。

英文:

Not really.

You can use the Maven shade plugin to construct a shaded jar that contains the dependency with a different package hierarchy.

But the usual solution is to try to find a version of the library that works with all of the other stuff (not always possible, I know).

huangapple
  • 本文由 发表于 2020年5月5日 14:23:01
  • 转载请务必保留本文链接:https://java.coder-hub.com/61606962.html
匿名

发表评论

匿名网友

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

确定