启动工程时出现异常:
项目中所有Dao实现类都继承了自定义的BaseDaoHibernate,而BaseDaoHibernate又继承了HibernateDaoSupport
BaseDaoHibernate extends HibernateDaoSupport
以前写配置文件时,sessionFactory需要单独配置,现在全注解方式,如何设置sessionFactory呢?
在BaseDaoHibernate中增加如下方法,使用@Autowired:
- 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:1477)
- at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
- ... 26 more
项目中所有Dao实现类都继承了自定义的BaseDaoHibernate,而BaseDaoHibernate又继承了HibernateDaoSupport
BaseDaoHibernate extends HibernateDaoSupport
以前写配置文件时,sessionFactory需要单独配置,现在全注解方式,如何设置sessionFactory呢?
在BaseDaoHibernate中增加如下方法,使用@Autowired:
- @Autowired
- public void setSessionFactoryOverride(SessionFactory sessionFactory)
- {
- super.setSessionFactory(sessionFactory);
- }