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

我的工程中用到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目录中,成功运行

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值