SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/Users/ASUS/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/D:/Maven/apache-maven-3.6.3/mvn_resp/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.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]
时间: 2023-08-05 12:06:14 浏览: 298
解决SLF4J: Failed to load class "org.slf
引用\[1\]、\[2\]和\[3\]中提到的错误信息都是关于SLF4J的类路径包含多个绑定的问题。这个问题通常是由于项目中引入了多个SLF4J的实现导致的。SLF4J是一个日志门面框架,它提供了统一的日志接口,而具体的日志实现可以通过不同的绑定来实现,比如log4j、logback等。当项目中引入了多个SLF4J的实现时,就会出现类路径包含多个SLF4J绑定的错误。
解决这个问题的方法是排除项目中多余的SLF4J实现。可以通过以下步骤来解决:
1. 首先,查看项目的依赖关系,确定项目中引入了哪些SLF4J的实现。可以通过查看项目的pom.xml文件或者构建工具的依赖管理工具来查看。
2. 找到多余的SLF4J实现,并将其排除。可以通过在pom.xml文件中添加排除依赖的配置来实现。例如,如果项目中引入了log4j-slf4j-impl和logback-classic两个实现,可以在pom.xml文件中排除其中一个实现,例如排除logback-classic:
```xml
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.10.0</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
```
3. 重新构建项目,确保只有一个SLF4J的实现被引入。
通过以上步骤,可以解决SLF4J类路径包含多个绑定的问题,并确保项目中只有一个SLF4J的实现被使用。\[1\]\[2\]\[3\]
#### 引用[.reference_title]
- *1* [SLF4J: Class path contains multiple SLF4J bindings. 问题原因及解决方法。](https://blog.csdn.net/SilenceCarrot/article/details/80609401)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Class path contains multiple SLF4J bindings.问题原因及解决方案](https://blog.csdn.net/hsuehgw/article/details/128057054)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [IDEA运行报错:slf4j:Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/...](https://blog.csdn.net/qq_44425201/article/details/120863321)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文