java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required
Errorcreatingbeanwithname'roleDao'definedinfile[E:\Java\workspace\ssh\build\classes\c...
Error creating bean with name 'roleDao' defined in file [E:\Java\workspace\ssh\build\classes\cn\com\examples\dao\base\RoleDao.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required——请问怎么向roleDao中注入sessionFactory?
展开
1个回答
展开全部
spring配置文件中写,
<bean name="roleDao" class="cn.com.examples.dao.base.RoleDao">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
cn.com.examples.dao.base.RoleDao类需要继承HibernateDaoSupport类!
<bean name="roleDao" class="cn.com.examples.dao.base.RoleDao">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
cn.com.examples.dao.base.RoleDao类需要继承HibernateDaoSupport类!
更多追问追答
追问
还是不行:Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory';
追答
你有在spring配置文件中写类似的配置么?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询