0

I have 2 external jars in my referenced libraries.

Both of the jars have a package with the same name.

Is there any way to specify which jar i want to use in the import or a way to work around this?

enter image description here

Error: enter image description here

3 Answers3

1

In the file where you are using the class, you have to give the full class name.

public com.mongodb.connection getDbDetail(){}

Vimit Dhawan
  • 597
  • 1
  • 7
  • 25
0

Actually, there are two ways of solving your problem:

  1. You can remove the dependency of one of the package from pom.xml which would remove the package from referenced libraries.
  2. Otherwise, if both packages are necessary for you then, you need to provide full qualified package name.
Jay
  • 312
  • 4
  • 15
0

Having the same package name like com.mongodb will not create any issue as long as the class name is unique. If both the jars have the same class name as ConnectionString but in different packages, use the fully qualified class name like com.mongodb.ConnectionString wherever referring to the corresponding class. If both the jars contain the same class name in the similar package, then you may end up something like NoSuchMethodError while accessing a particular method.

GirishB
  • 134
  • 7