Caused by: java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required
at org.springframework.orm.hibernate3.support.HibernateDaoSupport.checkDaoConfig(HibernateDaoSupport.java:118)
at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
... 32 more
原因:
我的com.hibernate.dao.impl.UserDAOImpl.java继承了org.springframework.orm.hibernate3.support.HibernateDaoSupport, spring在初始化容器的时候会对这个对象作一个check, 可以看看HibernateDaoSupport源码中的checkDaoConfig()方法
protected final void checkDaoConfig()
{
if (this.hibernateTemplate == null)
throw new IllegalArgumentException("'sessionFactory' or 'hibernateTemplate' is required");
}
所以,在com.hibernate.dao.impl.UserDAOImpl对象一定要注入一个sessionFactory or hibernateTemplate对
象。
<bean id="userDao" class="com.hibernate.dao.impl.UserDAOImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
标签:hibernate,java,spring,support,springframework,hibernateTemplate,报错,org,AbstractA From: https://blog.51cto.com/u_16229443/7135751