Failed to load class "org.slf4j.impl.StaticL

系统 1755 0

我的工程中用到hibernate3.3但运行时报如下错误

    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
	at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
	at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151)
	at org.easyshop.dao.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:14)
	at org.easyshop.dao.daoimp.CategoryDAOImpl.getTopCategoryList(CategoryDAOImpl.java:18)
	at org.easyshop.service.impl.ProductServiceImp.getTopCategoryList(ProductServiceImp.java:22)
	at org.easyshop.domain.test.main(test.java:13)
  

 很明显,少了slf4j相关的包。于是下载相关的slf4j包,我这里是slf4j1.5.5,(由于工程中用到log4j)因此选择解压后的

slf4j-log4j12-1.5.5.jar放工程的lib下,再运行报如下错:

    SLF4J: This version of SLF4J requires log4j version 1.2.12 or later. See also http://www.slf4j.org/codes.html#log4j_version
Exception in thread "main" java.lang.NoSuchFieldError: name
	at org.slf4j.impl.Log4jLoggerAdapter.<init>(Log4jLoggerAdapter.java:75)
	at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:75)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103)
	at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151)
	at org.easyshop.dao.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:14)
	at org.easyshop.dao.daoimp.CategoryDAOImpl.getTopCategoryList(CategoryDAOImpl.java:18)
	at org.easyshop.service.impl.ProductServiceImp.getTopCategoryList(ProductServiceImp.java:22)
	at org.easyshop.domain.test.main(test.java:13)

  

 提示工程中用到的log4j版本太低,于是下载log4j-1.2.15.jar放lib下,再运行如下错误

    Exception in thread "main" java.lang.NoSuchFieldError: name
	at org.slf4j.impl.Log4jLoggerAdapter.<init>(Log4jLoggerAdapter.java:75)
	at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:75)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:103)
	at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:151)
	at org.easyshop.dao.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:14)
	at org.easyshop.dao.daoimp.CategoryDAOImpl.getTopCategoryList(CategoryDAOImpl.java:18)
	at org.easyshop.service.impl.ProductServiceImp.getTopCategoryList(ProductServiceImp.java:22)
	at org.easyshop.domain.test.main(test.java:13)

  

 提示,相关类缺少字段name,于是到slf4j-log4j12-1.5.5里寻到Log4jLoggerAdapter类,确实看似少定义了name属性。但这样想就在错特错了,事实上是hibernate3.3里自带了slf4j-api-1.4.2.jar这个包,它和slf4j-log4j12-1.5.5版本不同,因此我在此纠结了N久~~最后将其删除,把slf4j-api-1.5.5.jar引入lib目录中,成功运行

Failed to load class "org.slf4j.impl.StaticLogger


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论