Dreamer
Dreamer

Reputation: 7551

How to find which dependency current jar file is referred?

In Eclipse, expand current project in project explorer,

click Java Resources -> libraries -> Maven Dependencies

And I found there are two jar files which in different version, i.e.:

commons-lang-2.1.jar
and
commons-lang3-3.1.jar

but from pom.xml, I cannot tell where commons-lang-2.1.jar come from as it must required by one of the artifacts. But it is too much trouble to check pom file from each artifact...

I heard of dependency-tree can work something similar but don't know how to make it work under this situation. Any hint is appreciated.

Upvotes: 0

Views: 1841

Answers (2)

Jigar Joshi
Jigar Joshi

Reputation: 240860

execute

mvn dependency:tree

if you have very giant dependency tree and hard to read you can use

mvn dependency:tree -Dincludes=org.apache.commons:commons-lang3

to just include occurrence of this artifact

from your pom.xml it will list out all the dependencies being pulled directly or indirectly, and put the <exclusion> to avoid consumption of non desired library

Upvotes: 2

Dave Newton
Dave Newton

Reputation: 160170

mvn dependency:tree

Look for the two instances of commons-lang and see what requires them.

That said, the two versions aren't compatible, and can live in the same application:

http://commons.apache.org/proper/commons-lang/article3_0.html

See this answer of mine regarding deciphering the tree output. The nutshell is that indented libraries are dependencies of the non-indented library above it: a dependency tree.

Upvotes: 2

Related Questions