Dependencies version conflict -> different slf4j versions but can't exclude wrong one
Clash Royale CLAN TAG#URR8PPP
Dependencies version conflict -> different slf4j versions but can't exclude wrong one
I've got almost same question like was asked here:
Maven + SLF4J: Version conflict when using two different dependencies that require two different SLF4J versions
(but unfortunately all answers didn't help our case)
Case:
I need to include firebase dependency
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>5.11.0</version>
</dependency>
Which depends on slf4j version 1.7.25.
Afterwards we implemented some integration test (using spring and junit) and now we're facing the clash
SLF4J: The requested version 1.5.6 by your slf4j binding is not compatible with [1.6, 1.7]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
But when I run " mvn dependency:tree" I don't see any other dependency on slf4j. So it's clearly something "outside" of the project.
I'm also unable to just exclude the slf4j from firebase because it's mandatory and I'm unable to use it without it.
Is there any chance how to check where the dependency comes from or how to exclude the older version (in case that it's gonna work with the newer one)?
1 Answer
1
Important rule: Declaring a dependency on an artifact A, say version v, in a local project P overrides other declarations made by the dependencies of P on A. Your project will have A version v imported, regardless the version(s) declared by your other dependencies for A.
In your case, declare explicitly the dependencies you want for slf4j-api as well as the desired binding.
See also Introduction to the Dependency Mechanism which states:
Dependency mediation - this determines what version of a dependency
will be used when multiple versions of an artifact are encountered.
Currently, Maven 2.0 only supports using the "nearest definition"
which means that it will use the version of the closest dependency to
your project in the tree of dependencies. You can always guarantee a
version by declaring it explicitly in your project's POM
Thank you for reply. Unfortunately this didn't help, when I specify version desired by Firebase (1.7.25) -> I'll get the same error that >SLF4J: The requested version 1.5.6 by your slf4j binding is not compatible with [1.6, 1.7] and when I exactly specify the lower version (let's say 1.5.6) -> then there are some missing features for firebase so it won't event compile.
– Radim
Aug 8 at 6:20
You need to explicitly declare BOTH slf4j-api and your desired BINDING.
– Ceki
Aug 8 at 12:27
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Please provide your dependency tree in the question.
– Ceki
Aug 7 at 19:42