-1

I have a maven project which has the direct dependency as follows:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.5</version>
    <scope>compile</scope>
    <optional>false</optional>
</dependency>

but in spite of this, the mvn dependency:tree shows slf4j-api version chosen as 1.6.2, and as direct dependency to my project!

There are other dependencies in my project which might depend on some other version of slf4j. But my understanding is that the version specified nearest to the root of the tree is picked up.

Other dependencies on slf4j related stuff are org.slf4j:jul-to-slf4j:jar:1.7.5:compile, org.slf4j:log4j-over-slf4j:jar:1.7.5:compile (direct dependencies) and org.slf4j:jcl-over-slf4j:jar:1.7.3:runtime (transitive dependency)

I am building a war in this maven project, and the jar of slf4j included is at 1.6.2 in the archive. I don't know what to do to make sure I get the jar version 1.7.5 and not 1.6.2.

Update: I am using maven 3.0.4.

Update 2: As requested, the pom and the debug logs are added. Since the files were huge, I've added it to dropbox Public folder: https://www.dropbox.com/sh/w1rtgvxvnt4jf18/lbiMIgwWD_

messivanio
  • 2,263
  • 18
  • 24
Aman
  • 639
  • 1
  • 9
  • 25
  • There may be some other dependency _requiring_ version 1.6.2 specifically `[1.6.2]`... Heres a good write up: http://guntherpopp.blogspot.com/2011/02/understanding-maven-dependency.html – Lucas Apr 02 '13 at 22:43
  • @Lucas how does someone require 1.6.2 specifically? If someone gave the version as [1.6.2] in square brackets, it would fail to resolve dependencies. But build is successful. Btw, I already read that writeup trying to search for solutions on google :-) – Aman Apr 02 '13 at 22:48
  • Possible duplicate: [Maven: remove a single transitive dependency](http://stackoverflow.com/questions/816858/maven-remove-a-single-transitive-dependency) – Chad Nouis Apr 02 '13 at 23:06
  • 1
    Post the output of `mvn dependency:tree -Ddebug` (as well as your full `pom.xml`). – carlspring Apr 03 '13 at 00:53
  • Please avoid putting things behind a link. There is lots of room in your post. – Simon Forsberg Sep 07 '16 at 15:05

1 Answers1

0

Indeed, proximity rules apply so that the declaration nearest the current project wins. You might want to remove the <optional>false</optional> element and see if it makes a difference.

Ceki
  • 26,753
  • 7
  • 62
  • 71