严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cn.qingyou.elec.dao.impl.DeviceDaoImpl': 
这是什么情况。
public interface DeviceDao extends BaseDao<Device> {
public final static String SERVICE_NAME="cn.qingyou.elec.dao.impl.DeviceDaoImpl";
}
@Repository(DeviceDao.SERVICE_NAME)
public class DeviceDaoImpl extends BaseDaoImpl<Device> implements DeviceDao {

}

解决方案 »

  1.   

    查一下你的 package 里有没有这个 class:
    cn.qingyou.elec.dao.impl.DeviceDaoImpl
      

  2.   


    更正一下:
    出错:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cn.qingyou.elec.dao.impl.DeviceDaoImpl': Injection of resource methods failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory
    这是什么情况。
    public interface DeviceDao extends BaseDao<Device> {
    public final static String SERVICE_NAME="cn.qingyou.elec.dao.impl.DeviceDaoImpl";
    }
    @Repository(DeviceDao.SERVICE_NAME)
    public class DeviceDaoImpl extends BaseDaoImpl<Device> implements DeviceDao {

    }
    applicationContext.xml文件:<?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!--1.配置注解自动扫描与装配bean -->
    <context:component-scan base-package="cn.qingyou.elec"></context:component-scan>

    <!-- 2.加载数据库连接信息文件-->
    <context:property-placeholder location="classpath:jdbc.properties" /> <!-- 3.配置SessionFactory(与Hibernate整合的入囗) -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

    <!-- 指定Hibernate的配置文件的位置 ,在类路径下寻找-->
    <property name="configLocation" value="classpath:hibernate.cfg.xml"></property>

    <!-- 4.配置DataSource -->
    <property name="dataSource">
    <bean class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <!-- 数据库连接信息 -->
    <property name="jdbcUrl" value="${jdbcUrl}"></property>
    <property name="driverClass" value="${driverClass}"></property>
    <property name="user" value="${username}"></property>
    <property name="password" value="${password}"></property>
    <!-- 其他一些配置 -->
    <property name="initialPoolSize" value="3"></property>
    <property name="minPoolSize" value="3"></property>
    <property name="maxPoolSize" value="15"></property>
    <property name="acquireIncrement" value="3"></property>
    <property name="maxStatements" value="8"></property>
    <property name="maxStatementsPerConnection" value="5"></property>
    <property name="maxIdleTime" value="1800"></property>
    </bean>
    </property>
    </bean>
    <!-- 5.配置声明式事务,使用基于注解的方式 -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <!-- 把SessionFactory注入进来 -->
    <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>

    <!-- 6.使用基于注解的方式 -->
    <tx:annotation-driven transaction-manager="transactionManager"/>
    </beans>
      

  3.   

     class都有的。以前这样做都没这种问题啊
      

  4.   

    你问题的直接原因应该是这个IllegalAccessError。org.slf4j.impl.StaticLoggerBinder.SINGLETON 的访问,在旧版本中是允许的,但是在新版(大概是1.5.6及以后),变为 private 了。猜测有可能的情况是,你的 slf4j 的版本有问题。大概是slf4j-api用的是旧版,而slf4j的implementation用的是新版。统一用新版(当然了,统一用旧版,也行),应能解决问题。