Issue
I getting this warning while running application.
I tried solution [here][1] but it is not working ,I am not sure what am I missing, could anyone help here? Thanks in advance.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/macuser/.m2/repository/ch/qos/logback/logback-classic/1.2.10/logback-classic-1.2.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/macuser/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.17.1/log4j-slf4j-impl-2.17.1.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 [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Parent Pom.xml after running mvn dependency:tree
[INFO] com.share:ekacloud-backend-share:pom:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.6.3:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.6.3:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.6.3:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.6.3:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.2.10:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.2.10:compile
[INFO] | | | +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.17.1:compile
[INFO] | | | \- org.slf4j:jul-to-slf4j:jar:1.7.33:compile
[INFO] | | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | | +- org.springframework:spring-core:jar:5.3.15:compile
[INFO] | | | \- org.springframework:spring-jcl:jar:5.3.15:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.29:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.6.3:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.13.1:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.1:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.13.1:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.6.3:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.56:compile
[INFO] | | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.56:compile
[INFO] | | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.56:compile
[INFO] | +- org.springframework:spring-web:jar:5.3.15:compile
[INFO] | | \- org.springframework:spring-beans:jar:5.3.15:compile
[INFO] | \- org.springframework:spring-webmvc:jar:5.3.15:compile
[INFO] | +- org.springframework:spring-aop:jar:5.3.15:compile
[INFO] | +- org.springframework:spring-context:jar:5.3.15:compile
[INFO] | \- org.springframework:spring-expression:jar:5.3.15:compile
[INFO] +- org.apache.commons:commons-collections4:jar:4.4:compile
[INFO] +- com.commons:commons-cache:jar:0.0.81:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.6.3:compile
[INFO] | +- org.springframework.data:spring-data-redis:jar:2.6.1:compile
[INFO] | | +- org.springframework.data:spring-data-keyvalue:jar:2.6.1:compile
[INFO] | | | \- org.springframework.data:spring-data-commons:jar:2.6.1:compile
[INFO] | | +- org.springframework:spring-tx:jar:5.3.15:compile
[INFO] | | +- org.springframework:spring-oxm:jar:5.3.15:compile
[INFO] | | \- org.springframework:spring-context-support:jar:5.3.15:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] | \- com.google.code.gson:gson:jar:2.8.9:compile
[INFO] +- com.github.docker-java:docker-java:jar:3.0.13:compile
[INFO] | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.13.1:compile
[INFO] | | +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.13.1:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.13.1:compile
[INFO] | | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] | +- org.glassfish.jersey.connectors:jersey-apache-connector:jar:2.35:compile
[INFO] | | +- org.glassfish.jersey.core:jersey-common:jar:2.35:compile
[INFO] | | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.3:compile
[INFO] | | \- jakarta.ws.rs:jakarta.ws.rs-api:jar:2.1.6:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.15:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
[INFO] | +- org.glassfish.jersey.core:jersey-client:jar:2.35:compile
[INFO] | | \- org.glassfish.hk2.external:jakarta.inject:jar:2.6.1:compile
[INFO] | +- com.kohlschutter.junixsocket:junixsocket-common:jar:2.0.4:compile
[INFO] | | \- log4j:log4j:jar:1.2.17:compile
[INFO] | +- com.kohlschutter.junixsocket:junixsocket-native-common:jar:2.0.4:compile
[INFO] | | \- org.scijava:native-lib-loader:jar:2.0.2:compile
[INFO] | +- org.apache.commons:commons-compress:jar:1.12:compile
[INFO] | +- commons-codec:commons-codec:jar:1.15:compile
[INFO] | +- commons-lang:commons-lang:jar:2.6:compile
[INFO] | +- commons-io:commons-io:jar:2.5:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.33:compile
[INFO] | +- org.slf4j:jcl-over-slf4j:jar:1.7.33:compile
[INFO] | +- com.google.guava:guava:jar:19.0:compile
[INFO] | +- org.bouncycastle:bcpkix-jdk15on:jar:1.54:compile
[INFO] | | \- org.bouncycastle:bcprov-jdk15on:jar:1.54:compile
[INFO] | +- io.netty:netty-codec-http:jar:4.1.73.Final:compile
[INFO] | | +- io.netty:netty-common:jar:4.1.73.Final:compile
[INFO] | | +- io.netty:netty-buffer:jar:4.1.73.Final:compile
[INFO] | | +- io.netty:netty-transport:jar:4.1.73.Final:compile
[INFO] | | \- io.netty:netty-codec:jar:4.1.73.Final:compile
[INFO] | +- io.netty:netty-handler:jar:4.1.73.Final:compile
[INFO] | | +- io.netty:netty-resolver:jar:4.1.73.Final:compile
[INFO] | | \- io.netty:netty-tcnative-classes:jar:2.0.46.Final:compile
[INFO] | +- io.netty:netty-handler-proxy:jar:4.1.73.Final:compile
[INFO] | | \- io.netty:netty-codec-socks:jar:4.1.73.Final:compile
[INFO] | +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.73.Final:compile
[INFO] | | +- io.netty:netty-transport-native-unix-common:jar:4.1.73.Final:compile
[INFO] | | \- io.netty:netty-transport-classes-epoll:jar:4.1.73.Final:compile
[INFO] | \- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.73.Final:compile
[INFO] | \- io.netty:netty-transport-classes-kqueue:jar:4.1.73.Final:compile
[INFO] +- com.commons:commons-ssm:jar:0.0.81:compile
[INFO] | \- com.amazonaws:aws-java-sdk-ssm:jar:1.11.225:compile
[INFO] | +- com.amazonaws:aws-java-sdk-core:jar:1.11.225:compile
[INFO] | | +- software.amazon.ion:ion-java:jar:1.0.2:compile
[INFO] | | +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.13.1:compile
[INFO] | | \- joda-time:joda-time:jar:2.8.1:compile
[INFO] | \- com.amazonaws:jmespath-java:jar:1.11.225:compile
[INFO] +- com.commons:commons-error:jar:0.0.81:compile
[INFO] +- com.commons:commons-client:jar:0.0.81:compile
[INFO] +- com.commons:commons-util:jar:0.0.81:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.13.1:compile
[INFO] | | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.1:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-core:jar:2.13.1:compile
[INFO] | \- javax.servlet:javax.servlet-api:jar:4.0.1:compile
[INFO] +- com.commons:commons-model:jar:0.0.81:compile
[INFO] | +- org.springframework.security:spring-security-core:jar:5.6.1:compile
[INFO] | | \- org.springframework.security:spring-security-crypto:jar:5.6.1:compile
[INFO] | +- io.swagger:swagger-annotations:jar:1.5.13:compile
[INFO] | +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] | \- com:ess-model-java:jar:1.6.0:compile
[INFO] | +- io.gsonfire:gson-fire:jar:1.8.0:runtime
[INFO] | \- javax.annotation:javax.annotation-api:jar:1.3.2:runtime
[INFO] +- org.powermock:powermock-module-junit4:jar:1.7.4:compile
[INFO] | +- org.powermock:powermock-module-junit4-common:jar:1.7.4:compile
[INFO] | | +- org.powermock:powermock-reflect:jar:1.7.4:compile
[INFO] | | \- org.powermock:powermock-core:jar:1.7.4:compile
[INFO] | | \- org.javassist:javassist:jar:3.21.0-GA:compile
[INFO] | +- junit:junit:jar:4.13.2:compile
[INFO] | \- org.hamcrest:hamcrest-core:jar:2.2:compile
[INFO] | \- org.hamcrest:hamcrest:jar:2.2:compile
[INFO] +- com.github.kstyrc:embedded-redis:jar:0.6:compile
[INFO] +- com.squareup.okhttp3:okhttp:jar:3.8.1:compile
[INFO] | \- com.squareup.okio:okio:jar:1.13.0:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.17.1:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.17.1:compile
[INFO] +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.17.1:compile
[INFO] +- org.powermock:powermock-api-mockito2:jar:1.7.4:test
[INFO] | \- org.powermock:powermock-api-mockito-common:jar:1.7.4:test
[INFO] | \- org.powermock:powermock-api-support:jar:1.7.4:test
[INFO] +- org.flywaydb:flyway-core:jar:4.2.0:compile
[INFO] +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] | \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] \- org.mockito:mockito-core:jar:4.3.1:test
[INFO] +- net.bytebuddy:byte-buddy:jar:1.11.22:test
[INFO] +- net.bytebuddy:byte-buddy-agent:jar:1.11.22:test
[INFO] \- org.objenesis:objenesis:jar:3.2:compile
I thought it is coming from spring-boot-starter-web and tried to add exclusion here but it did not work.
Solution
You have to use the information SLF4J provide you and back trace the dependency using dependency:tree
and its includes
option.
This message:
SLF4J: Found binding in [jar:file:/Users/macuser/.m2/repository/ch/qos/logback/logback-classic/1.2.10/logback-classic-1.2.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/macuser/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.17.1/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
Means that the following dependencies are being imported:
ch.qos.logback:logback-classic:1.2.10:jar
org.apache.logging.log4j:log4j-slf4j-impl:2.17.1:jar
Then you can filter your dependency tree using -Dincludes=
mvn dependency:tree '-Dincludes=ch.qos.logback:logback-classic,org.apache.logging.log4j:log4j-slf4j-impl'
You may omit the version and type here because that's not really important.
This will give you the exact dependencies you will have to exclude.
And from the dependencies you reference, I think your problem lies in the use of Log4J2 with a SLF4J bindings whereas spring boot use SLF4J with Logback as default implementation.
You can read this to use log4j2 with Spring boot: https://www.callicoder.com/spring-boot-log4j-2-example/
Answered By - NoDataFound
Answer Checked By - Gilberto Lyons (JavaFixing Admin)