SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/Users/taosun/.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:/Users/taosun/.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] 31 五月 2023 17:12:51 [main] INFO Cache with name 'com.little.service.realm.MyRealm.authorizationCache' does not yet exist. Creating now.服务无法启动怎么办
时间: 2023-08-25 20:07:27 浏览: 296
这个错误信息提示了你的应用中存在多个 SLF4J 的绑定,而且这可能会导致应用启动失败。可以按照提示的链接去查看说明,了解原因和解决方法。
一般来说,可以通过排除不需要的 SLF4J 绑定来解决这个问题。在 Maven 的 pom.xml 文件中,可以添加如下的配置,排除 log4j-slf4j-impl:
```
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
```
如果不想排除 log4j-slf4j-impl,也可以排除 logback-classic,或者通过其他方法解决。但是需要注意,解决这个问题可能会影响应用的日志输出和性能。
相关问题
[atguigu@node11 hbase]$ ./bin/start-hbase.sh SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.1.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/client-facing-thirdparty/slf4j-log4j12-1.7.30.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 [org.slf4j.impl.Log4jLoggerFactory] running master, logging to /usr/local/hbase/bin/../logs/hbase-atguigu-master-node11.out SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.1.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/client-facing-thirdparty/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation怎么办
这个问题是因为在类路径(classpath)中出现了多个SLF4J绑定的原因。可以尝试以下解决方案:
1. 在`$HBASE_HOME/conf/hbase-env.sh`中添加以下代码:
```
export HBASE_OPTS="$HBASE_OPTS -Dorg.slf4j.simpleLogger.showMultipleLoggers=true"
```
这样可以在启动时查看具体的多绑定信息。
2. 在`$HBASE_HOME/conf/log4j.properties`中添加以下代码:
```
# Remove duplicate SLF4J bindings
log4j.logger.org.apache.hadoop.metrics2=ERROR,console
```
这样可以将日志级别调整为ERROR,从而隐藏多绑定的警告信息。
3. 如果以上两种方法均未解决问题,可以考虑移除多余的SLF4J绑定。具体方法是在HBase的类路径中只保留一个SLF4J绑定的jar包,删除其他的绑定jar包。
[atguigu@node11 hbase]$ bin/start-hbase.sh SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.1.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/client-facing-thirdparty/slf4j-log4j12-1.7.30.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 [org.slf4j.impl.Log4jLoggerFactory] running master, logging to /usr/local/hbase/bin/../logs/hbase-atguigu-master-node11.out SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/module/hadoop-3.1.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/client-facing-thirdparty/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation
这是一个启动HBase的Shell脚本,在启动的过程中出现了SLF4J绑定的问题。具体的错误信息是Class path contains multiple SLF4J bindings,意思是类路径中包含了多个SLF4J绑定。在这个错误信息中,SLF4J发现了两个绑定,一个在/opt/module/hadoop-3.1.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar中,另一个在/usr/local/hbase/lib/client-facing-thirdparty/slf4j-log4j12-1.7.30.jar中。SLF4J提供了一个链接http://www.slf4j.org/codes.html#multiple_bindings来解释这个问题。最后,该错误信息指出实际的绑定类型是org.slf4j.impl.Log4jLoggerFactory。
阅读全文