Maven SLF4J: Class path contains multiple SLF4J bindings

前端 未结 5 2160
北恋
北恋 2020-12-08 07:42

I am getting following runtime Exception while running my java code. Could someone please help me resolve the binding conflicts.

    SLF4J: Class path contai         


        
相关标签:
5条回答
  • 2020-12-08 08:10

    This Works !! Update the porm.xml

    <dependency>
    <groupId>org.someexternallib</groupId>
    <artifactId>someexternallibartifact</artifactId>
    <version>...</version>
    
    <exclusions>
       <exclusion> 
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
       </exclusion>
       <exclusion> 
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
      </exclusion>
    </exclusions> 
    

    0 讨论(0)
  • 2020-12-08 08:11

    Run mvn dependency:tree and search which dependency have the slf4j implementations you do not want, then exclude them with a dependency exclusion like:

    <dependency>
        <groupId>org.someexternallib</groupId>
        <artifactId>someexternallibartifact</artifactId>
        <version>...</version>
    
        <exclusions>
           <exclusion> 
              <groupId>org.slf4j</groupId>
              <artifactId>slf4j-log4j12</artifactId>
           </exclusion>
           <exclusion> 
              <groupId>log4j</groupId>
              <artifactId>log4j</artifactId>
          </exclusion>
        </exclusions> 
    </dependency>
    
    0 讨论(0)
  • 2020-12-08 08:18

    You can go to POM.xml , open Dependency Hierarchy and find slf4j entries.Except one exclude rest of them by right clicking "exclude maven artifact"

    0 讨论(0)
  • 2020-12-08 08:21

    This error means that you have multiple implementations of SLF4J in your classpath. Look for what the errors are specifically saying. i.e : SLf4J: Found binding in..... (This will print all the jar files where it found instances of StaticLoggerBinder.class). Eliminate all such jars from your classpath, except the jar whose StaticLoggerBinder.class implementation you need.

    0 讨论(0)
  • 2020-12-08 08:23

    It seems you have several implementation of SLF4J; you should exclude all the not necessary ones

    0 讨论(0)
提交回复
热议问题