运行maven程序时报如下错误:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

以下是 错误的解决办法:

上百度查了下,百度千篇一律复制的博客各种解决办法无非是添加以下这些依赖:

<dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.12</version></dependency><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>1.7.25</version></dependency><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId><version>1.7.25</version>
</dependency>

以下是 正确的解决办法:

以上都没效果,点开报错网址进官网一看:

http://www.slf4j.org/codes.html#StaticLoggerBinder

Multiple bindings were found on the class path

SLF4J API is designed to bind with one and only one underlying logging framework at a time. If more than one binding is present on the class path, SLF4J will emit a warning, listing the location of those bindings.

When multiple bindings are available on the class path, select one and only one binding you wish to use, and remove the other bindings. For example, if you have bothslf4j-simple-2.0.0-alpha0.jarandslf4j-nop-2.0.0-alpha0.jaron the class path and you wish to use the nop (no-operation) binding, then removeslf4j-simple-2.0.0-alpha0.jarfrom the class path.

The list of locations that SLF4J provides in this warning usually provides sufficient information to identify the dependency transitively pulling in an unwanted SLF4J binding into your project. In your project's pom.xml file, exclude this SLF4J binding when declaring the unscrupulous dependency. For example,cassandra-allversion 0.8.1 declares bothlog4jandslf4j-log4j12as compile-time dependencies. Thus, when you includecassandra-allas a dependency in your project, thecassandra-alldeclaration will cause bothslf4j-log4j12.jarandlog4j.jarto be pulled in as dependencies. In case you do not wish to use log4j as the the SLF4J backend, you can instruct Maven to exclude these two artifacts as shown next:

<dependencies>
  <dependency>
    <groupId>org.apache.cassandra</groupId>
    <artifactId>cassandra-all</artifactId>
    <version>0.8.1</version>

<exclusions>
      <exclusion> 
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
      </exclusion>
      <exclusion> 
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
      </exclusion>
    </exclusions>

</dependency>
</dependencies>

NOTEThe warning emitted by SLF4J is just that, a warning. Even when multiple bindings are present, SLF4J will pick one logging framework/implementation and bind with it. The way SLF4J picks a binding is determined by the JVM and for all practical purposes should be considered random. As of version 1.6.6, SLF4J will name the framework/implementation class it is actually bound to.

Embedded components such as libraries or frameworks should not declare a dependency on any SLF4J binding but only depend on slf4j-api. When a library declares a compile-time dependency on a SLF4J binding, it imposes that binding on the end-user, thus negating SLF4J's purpose. When you come across an embedded component declaring a compile-time dependency on any SLF4J binding, please take the time to contact the authors of said component/library and kindly ask them to mend their ways.

大致意思是SLF4J发出的警告仅是警告。即使存在多个绑定,SLF4J也会选择一个日志记录框架/实现并与其绑定。

添加这个依赖就完美解决问题:

<dependencies><dependency><groupId> org.apache.cassandra</groupId><artifactId>cassandra-all</artifactId><version>0.8.1</version><exclusions><exclusion> <groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId></exclusion><exclusion> <groupId>log4j</groupId><artifactId>log4j</artifactId></exclusion></exclusions> </dependency>
</dependencies>

总结:多看官网

slf4j报错:SLF4J:Failed to load class org.slf4j.impl.StaticLoggerBinder.Defaulting to no-operat有效解决办法相关推荐

  1. 接入谷歌AdSense后浏览器控制台报错:Failed to load resource: the server responded with a status of 403的原因及解决办法、

    本篇文章主要讲解,接入谷歌AdSense后浏览器控制台报错:Failed to load resource: the server responded with a status of 403 ads ...

  2. HTML页面跨域请求图片资源报错:Failed to load resource: the server responded with a status of 403 (Forbidden)

    笔者近日刚刚完成了一个Spring boot项目,首页 index.html 页面元素 <img> 引用了第三方服务器的图片链接,在本地测试环境输入 http://localhost 或者 ...

  3. 控制台出现报错DevTools failed to load source map: Could not load content for chrome-extension://的原因及解决方案

    控制台出现报错DevTools failed to load source map: Could not load content for chrome-extension://的原因及解决方案 在调 ...

  4. python报错:xml.parsers.expat.ExpatError: not well-formed (invalid token): line 3, column 1的解决办法

    本篇文章主要讲解,python报错:xml.parsers.expat.ExpatError: not well-formed (invalid token): line 3, column 1的解决 ...

  5. 【已解决】启动Python报错api-ms-win-crt-process-l1-1-0.dll缺失,windows7无法升级,升级补丁打不上的解决办法

    [已解决]启动Python报错api-ms-win-crt-process-l1-1-0.dll缺失,windows7无法升级,升级补丁打不上的解决办法 问题:启动python报错api-ms-win ...

  6. eclipse打开报错:Failed to load the JNI shared library

    1.启动eclipse出现如下报错: 弹出框显示:Failed to load the JNI shared library 2.出现原因以及解决办法: (1)原因1:JDK和eclipse位数不匹配 ...

  7. 小程序报错:Failed to load local image resource /pages/goods/NaN加载资源失败问题解决

    小程序开发的时候遇到Failed to load local image resource /pages/goods/NaN 这个报错,有点懵逼,小程序上面也没发现有哪张图片显示不出来.只能用最笨的方 ...

  8. eclipse报错:Failed to load the JNI shared library

    Eclipse运行时提示"Failed to load the JNI shared library /Java/jre6/bin/client/jvm.dll"的一个解决方案 因 ...

  9. spring单元测试报错:Failed to load ApplicationContext 的解决方法

    使用idea 配置单元测试之后,配置完spring的注解@junit 和@runer 之后 一直报错. 最后发现是默认使用jdk1.8引起的,使用jdk1.7即可. 转载于:https://www.c ...

  10. vite项目在jenkins自动打包报错:failed to load config from ../vite.config.js You installed esbuild on

    vite项目在jenkins自动打包报错找不到esbuild-linux-64 在window环境开发用的找不到esbuild-windows-64,在linux环境构建需要使用esbuild-lin ...

最新文章

  1. 宁波大红鹰学院计算机科学与技术,2019宁波大红鹰学院专业排名
  2. OpenCV-Python:实现人脸、人眼、嘴巴识别
  3. oracle linux 6.5 安装 virtualbox
  4. 从工作实践中积累Linux常用脚本(一)
  5. java怎么将前端的数据存到关联的表中_Java程序员最可能被考到的14个面试题
  6. React组件生命周期-正确执行运行阶段的函数
  7. 动态库在不同操作系统中的不同意义
  8. 快讯:2019 OOW 文档已提供下载
  9. 【整理总结】代码沉淀 - Caliburn.Micro - MV*模式短小精悍的框架
  10. php小总结之 mysqli面向过程、面向对象和PDO在增删改查使用中的一些小区别
  11. 炫酷而不复杂,RDP报表就是这么实用方便
  12. GB28181标准文档以及GB35114标准文档免费下载
  13. 快速合并所有txt文档
  14. IGBT简介、结构及原理
  15. python迷宫地图代码_python实现的生成随机迷宫算法核心代码分享(含游戏完整代码)...
  16. 联想服务器的主板型号怎么看,科技知识:联想主板型号怎么看
  17. OSWorkflow(转载)
  18. 我的滑板鞋-2017年在魅力之都继续摩擦
  19. java-learning:32. ArrayList类应用
  20. 分布式系统、集群的时间同步

热门文章

  1. 5G网优工程师需要会使用哪些软件?Mapinfo是必要!
  2. django 内置标签与过滤器
  3. android 多个catch,【Android开发坑系列】之try-catch
  4. 【GCC编译优化系列】宏定义名称与函数同名是一种什么骚操作?
  5. 康奈尔大学的计算机专业怎么样,美国名校康奈尔大学计算机专业介绍
  6. python怎么读取石墨表格_石墨这种多人文档编辑协作如何用开源软件实现?
  7. 运算放大器电路PCB的设计技巧
  8. STM32F103+VL53L0测距(一)
  9. 最强蜗牛换了手机找不到服务器,最强蜗牛怎么换服务器 换区换服务器全流程...
  10. ubuntu14.10+QT4编写ARM9(mini2440)应用的配置与安装