• maven项目启动报错:SLF4J: Class path contains multiple SLF4J bindings.


    SringBoot的Application启动报错:

    1 SLF4J: Class path contains multiple SLF4J bindings.
    2 SLF4J: Found binding in [jar:file:/G:/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    3 SLF4J: Found binding in [jar:file:/G:/.m2/repository/org/slf4j/slf4j-log4j12/1.7.21/slf4j-log4j12-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    4 SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    5 SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

    原因:logback-classic包和slf4j包冲突。 

    解决方法:

    找到哪个依赖引入了logback-classic,然后用依赖排除标签排除掉。

    具体解决:

    其中slf4j-log4j12包是我在pom中引入的,说明logback-classic包是其他依赖中引用的。在pom文件的Depency Hierarchy页签中,找到:

    是spring-boot-starter-jdbc包引入的。

    (也可以用mvn dependency:tree 命令查看依赖关系)

     在pom中排除掉:

     1 <dependency>
     2     <groupId>org.springframework.boot</groupId>
     3     <artifactId>spring-boot-starter-jdbc</artifactId>
     4 
     5         <!--排除-->
     6     <exclusions>
     7          <exclusion> 
     8          <groupId>ch.qos.logback</groupId>
     9          <artifactId>logback-classic</artifactId>
    10         </exclusion>
    11     </exclusions>
    12 
    13 </dependency>
  • 相关阅读:
    一张一驰,文武之道
    关于“未能加载……”和“web.config”
    DotText学习心得_1
    windows服务与事务
    AWR报告生成
    Java EE启示录
    跨入安全的殿堂读《Web入侵安全测试与对策》感悟
    用VS2005写Loadrunner测试脚本
    List of Free Programming books
    硬盘基础知多少
  • 原文地址:https://www.cnblogs.com/mySummer/p/9487725.html
Copyright © 2020-2023  润新知