Java – Error: SLF4J: Class path contains multiple SLF4J bindings

javamavenslf4j

I get the following error when I try to run my junit test in eclipse:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/MaximilianBecker/.m2/repository/uk/org/lidalia/slf4j-test/1.2.0/slf4j-test-1.2.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/MaximilianBecker/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [uk.org.lidalia.slf4jtest.TestLoggerFactory]

my pom.xml includes this:

<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
<version>1.1.0</version>
</dependency>

I implemented also this into my pom.xml:

<plugin>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <classpathDependencyExcludes>
      <classpathDependencyExcludes>ch.qos.logback:logback-classic</classpathDependencyExcludes>
    </classpathDependencyExcludes>
  </configuration>
</plugin>

and it is still not working and I get that error….. why?

Best Solution

SLF4J it's just provider to logging, which provides interface to other logging frameworks (e.g. slf4j-log4j12, slf4j-simple and other). And when in your project appears several slf4j implementation, then you're see this warning. Judging by your error, conflict arrises between logback-classic-1.1.7 and slf4j-test-1.2.0. Try to delete one of this dependencies.