2

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)?

Community
  • 1
  • 1
Radim
  • 164
  • 1
  • 4
  • 18

1 Answers1

0

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

Ceki
  • 26,753
  • 7
  • 62
  • 71
  • 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 08 '18 at 06:20
  • You need to explicitly declare BOTH slf4j-api and your desired BINDING. – Ceki Aug 08 '18 at 12:27