Spring注解方式,异常 'sessionFactory' or 'hibernateTemplate' is required的解决方法

启动工程时出现异常:
Java代码    收藏代码

        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:
Java代码    收藏代码

        @Autowired    
                 public void setSessionFactoryOverride(SessionFactory sessionFactory)    
                {    
            
                         super.setSessionFactory(sessionFactory);    
                }    

你可能感兴趣的:(java,异常,required,is)