Maven使用错误库中的类

发布于 2025-02-09 15:56:40 字数 605 浏览 1 评论 0原文

我目前正在研究一个Maven项目,其中包括很多外部库。现在我有以下问题...

问题:我有两个不同的库(假设 library a&amp; library b )都有一个类(让我们命名类< Strong> ABC.Class )具有相同的className,但类别没有相同的实现!现在,我的测试班之一使用 abc.class 来自库a ,这是错误的类/库。该测试级应使用 abc.class 来自库B 。我不能仅删除库a,因为我也需要其他测试级。

我的设置:

  • maven:apache-maven-3.6.1
  • java:jdk11
  • IDE:Intellij

我的问题:有没有办法为特定类别固定奇异库?因此,我可以将库b 固定到失败的测试阶级,因此它可以使用正确的库和正确的实现来实现 abc.class

在最好的情况下,我想在POM中修复它:)
请让我知道是否有可能。

i am currently working on a Maven project with alot external Libraries. Now i have following Issue...

Issue: I have two different Libraries(lets say Library A & Library B) and both have a class(lets name the class abc.class) with the same classname but the classes dont have the same Implementation! Now one of my testclasses uses abc.class from Library A, which is the wrong class/library. This testclass should use abc.class from Library B. I cant just delete the Library A because i needed also for other testclasses.

My SetUp:

  • Maven: apache-maven-3.6.1
  • Java: jdk11
  • IDE: IntelliJ

My Question: Is there a way to pin diffrent Libraries for specific classes? So i could pin the Library B to my failing testclass, so it can use the right Library and the right implementation for the abc.class.

In the best case, i would like to fix it in the POM :)
Pls let me know if its somehow possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枫林﹌晚霞¤ 2025-02-16 15:56:40

否。

您需要具有班级的兼容版本。

甚至更好地只包括一种类型的班级。

No.

You need to have compatible versions of the class.

Or even better only include one type of Class to your build.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文