Here is an output from mvn dependency:tree
Check the dependencies for kafka.
I see it coming at two places and want to know which dependency will come into play when the application is run.
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ suite ---
[INFO] com.company.foo.qe:suite:jar:2.8.0-SNAPSHOT
[INFO] +- org.apache.kafka:kafka_2.11:jar:0.8.2-V3-PATCH:compile
[INFO] | +- org.scala-lang.modules:scala-xml_2.11:jar:1.0.2:compile
[INFO] | +- com.yammer.metrics:metrics-core:jar:2.2.0:compile
[INFO] | +- net.sf.jopt-simple:jopt-simple:jar:3.2:compile
[INFO] | +- org.scala-lang.modules:scala-parser-combinators_2.11:jar:1.0.2:compile
[INFO] | +- org.scala-lang:scala-library:jar:2.11.2:compile
[INFO] | +- org.apache.kafka:kafka-clients:jar:0.8.2-V3-PATCH:compile
[INFO] | | \- net.jpountz.lz4:lz4:jar:1.2.0:compile
[INFO] +- com.company.foo:ec:jar:2.8.0-SNAPSHOT:compile
[INFO] | +- com.company.foo:solr:jar:2.8.0-SNAPSHOT:compile
[INFO] | +- org.apache.kafka:kafka_2.10:jar:0.8.1.1:compile
From the documentation: "By Default Maven will solve conflicts with a nearest-win approach" [Resolving Conflicts]. This translates to picking org.apache.kafka:kafka_2.11:jar:0.8.2-V3-PATCH:compile in your example. Also see Transitive Dependencies
The nearest-win approach just picks the version of the dependency closest to the left in the Maven dependency tree output. This approach chooses a dependency based on how close they are to your pom.xml dependency declaration. If you declare dependency conflicting-2.0 explicitly in your pom that dependency will be the one picked by Maven. If you declare dependency B which in turn depends on conflicting-1.0, then conflicting-1.0 would be considered to be further away that of conflicting-2.0 in your dependencies.
To exemplify :
In this case Maven would pick conflicting-2.0 as the right version for the dependency since it is declared explicitly in the project pom.
To be sure, you can invoke the dependency tree with the -Dverbose flag (
mvn dependency:tree -Dverbose
) and maven will tell you which jar is not picked: