日志jar包错误

Failed to load class org.slf4j.impl.StaticLoggerBinder
This warning message is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.

SINCE 1.6.0 As of SLF4J version 1.6, in the absence of a binding, SLF4J will default to a no-operation (NOP) logger implementation.

If you are responsible for packaging an application and do not care about logging, then placing slf4j-nop.jar on the class path of your application will get rid of this warning message. Note that 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.

未能加载类org.slf4j.inst.StaticLoggerBinder,当org.slf4j.inst.StaticLoggerBinder类无法加载到内存中时,将报告此警告消息。当在类路径上找不到适当的SLF4J绑定时,就会发生这种情况。将slf4j-nop.jar slf4j-simple.jar、slf4j-log4j12.jar、slf4j-jdk14.jar或Logback-classic.jar放置在类路径上应该可以解决这个问题。从1.6.0到SLF4J版本1.6,在没有绑定的情况下,SLF4J将默认为无操作(NOP)记录器实现。如果您负责打包应用程序,而不关心日志记录,那么将slf4j-nop.jar放在应用程序的类路径上将消除此警告消息。注意,嵌入组件(如库或框架)不应该声明依赖于任何SLF4J绑定,而应该只依赖于slf4j-API。当库声明对SLF4J绑定的编译时依赖时,它会将该绑定强加给最终用户,从而否定SLF4J的目的。

事故原因:—

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 both slf4j-simple-1.8.0-beta2.jar and slf4j-nop-1.8.0-beta2.jar on the class path and you wish to use the nop (no-operation) binding, then remove slf4j-simple-1.8.0-beta2.jar from 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-all version 0.8.1 declares both log4j and slf4j-log4j12 as compile-time dependencies. Thus, when you include cassandra-all as a dependency in your project, the cassandra-all declaration will cause both slf4j-log4j12.jar and log4j.jar to 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:
SLF4JAPI被设计为一次绑定一个并且只有一个底层日志框架。如果类路径上存在多个绑定,SLF4J将发出警告,列出这些绑定的位置。当类路径上有多个绑定可用时,选择一个也是唯一一个要使用的绑定,然后删除其他绑定。例如,如果类路径上有slf4j-Simple-1.8.0-beta2.jar和slf4j-NOP-1.8.0-beta2.jar,并且希望使用NOP(无操作)绑定,那么从类路径中删除slf4j-Simpl-1.8.0-beta2.jar。SLF4J在此警告中提供的位置列表通常提供足够的信息,以标识依赖关系,并将不需要的SLF4J绑定到您的项目中。在您的项目的put.xml文件中,在声明无良依赖时排除此SLF4J绑定。例如,Cassandra-All版本0.8.1声明log4j和slf4j-log4j12都是编译时依赖项。因此,当您将Cassandra-所有作为依赖项包含在您的项目中时,Cassandra-all声明将导致slf4j-log4j12.jar和log4j.jar作为依赖项被牵扯进来。如果不希望使用log4j作为SLF4J后端,可以指示Maven排除这两个工件,如下所示:

**解决办法~~~~~~~~~~~~~~**
在pom.xml文件中导入以下jar包


org.apache.cassandra
cassandra-all
0.8.1

<exclusions>
  <exclusion> 
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
  </exclusion>
  <exclusion> 
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
  </exclusion>
</exclusions> 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值