SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/D:/develop/maven/apache-maven-3.3.9/repo/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:/project/gjyw/ibms/ibms-service/lib/pierce-sdk-1.0.0-with-jdk8.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] Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:439) at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:418) at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:409) at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:261) at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:240) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) at com.sdhsie.ibms.Application.main(Application.java:14) Caused by: java.lang.IllegalArgumentException: class org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor is not assignable to interface org.springframework.context.ApplicationListener at org.springframework.util.Assert.assignableCheckFailed(Assert.java:655) at org.springframework.util.Assert.isAssignable(Assert.java:586) at org.springframework.util.Assert.isAssignable(Assert.java:617) at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:432) ... 7 more 如何解决
时间: 2023-09-18 21:11:31 浏览: 112
这个错误主要是由于多个SLF4J绑定存在于类路径中,导致实际绑定的类型不明确。可以尝试以下步骤解决:
1. 找到多个SLF4J绑定的jar包,将其中一个或者多个移除掉。
2. 确认项目中使用的SLF4J版本,然后保证所有的SLF4J jar包版本一致。
3. 如果是在Spring Boot项目中遇到这个错误,可以尝试通过排除Spring Boot默认的SLF4J依赖,然后手动添加所需的SLF4J依赖,来避免这个问题。
4. 可以参考SLF4J的官方文档,了解更多关于SLF4J绑定的信息和解决方法。
相关问题
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in
SLF4J(Simple Logging Facade for Java)是一个为Java应用程序提供日志记录的简单门面(facade)框架。它允许开发人员在应用程序中使用统一的API进行日志记录,而无需关注具体的日志实现细节。
关于你提到的错误信息"Class path contains multiple SLF4J bindings. SLF4J: Found binding in...",这是由于在应用程序的类路径中存在多个SLF4J绑定引起的。SLF4J只允许存在一个绑定,否则会导致冲突。
解决这个问题的方法是在应用程序的类路径中只保留一个SLF4J绑定。你可以通过以下步骤来解决这个问题:
1. 确定你的应用程序使用了哪些依赖项,并查找它们是否包含了SLF4J绑定。
2. 如果发现多个SLF4J绑定,选择其中一个并将其从依赖项中移除。
3. 如果你无法确定哪个依赖项包含了SLF4J绑定,可以尝试使用Maven或Gradle等构建工具来排除冲突的依赖项。
SLF4J: Class path contains multiple SLF4J providers.
SLF4J: Class path contains multiple SLF4J providers是一个错误信息,表示在项目的classpath中存在多个SLF4J提供者。这个问题通常会导致SLF4J无法确定使用哪个提供者,从而引发错误。
解决这个问题的方法是删除或排除冲突的SLF4J提供者。可以通过以下步骤来解决这个问题:
1. 首先,需要确定项目的依赖关系,尤其是与日志相关的依赖项。查看项目的pom.xml文件或构建配置文件,找到与SLF4J相关的依赖项。
2. 接下来,需要确定哪些依赖项导致了冲突。查找冲突的SLF4J提供者,可以在错误信息中找到类似"Found binding in"的内容,它会列出存在冲突的路径以及提供者的名称。
3. 一旦确定了冲突的提供者,可以选择将其中一个提供者从项目中移除。这可以通过在项目配置文件中排除依赖项或手动删除相关的jar文件来实现。
4. 如果移除冲突的提供者后仍然存在问题,可能需要查看项目的其他依赖项,确保它们与SLF4J的版本兼容。
总的来说,当出现SLF4J: Class path contains multiple SLF4J providers错误时,需要检查项目的依赖关系,找出冲突的SLF4J提供者并进行相应的调整。这样可以确保SLF4J能够正常工作并连接到正确的日志实现。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [SLF4J(二) - SLF4J绑定了多个实现类的错误是怎么一回事儿?源码解析](https://blog.csdn.net/sweetyi/article/details/104633321)[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^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![jar](https://img-home.csdnimg.cn/images/20210720083455.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)