简体   繁体   中英

Maven uses class from wrong Library

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.

No.

You need to have compatible versions of the class.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM