当前位置: 代码迷 >> J2EE >> 诡异的异常,明明注入了sessionFactory,还是报sessionFactory' or 'hibernateTemplate' is required
  详细解决方案

诡异的异常,明明注入了sessionFactory,还是报sessionFactory' or 'hibernateTemplate' is required

热度:558   发布时间:2016-04-17 23:46:20.0
诡异的错误,明明注入了sessionFactory,还是报sessionFactory' or 'hibernateTemplate' is required
以下是配置文件:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.OracleDialect
</prop>
</props>
</property>
</bean>
<bean id="whouseDao" class="lux.dao.impl.WhouseDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="whouseService" class="lux.service.impl.WhouseServiceImpl">
<property name="whouseDao">
<ref bean="whouseDao" />
</property>
</bean>
<bean id="whouseAction" class="lux.action.WhouseAction">
<property name="whouseService">
<ref bean="whouseService" />
</property>
</bean>
以下是报错内容:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'whouseService' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required

一共建了好几个和whouse类似的bean,配置都一样,别的都不报错,把whouse注释了之后也没问题。
请大家帮忙解决。
------解决方案--------------------
<bean id="whouseService" class="lux.service.impl.WhouseServiceImpl">
给红色的类配置一个
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
  相关解决方案