地址:http://blog.youkuaiyun.com/xinxin19881112/article/details/8916072
错误信息:
org.springframework.beans.NotWritablePropertyException: Invalid property 'sessionFactory' of bean class [dao.impl.UserDaoImpl]: Does the parameter type of the setter match the return type of the getter?
方法1、
在对应UserDaoImpl中加入sessionfactory的set方法、get方法。
private SessionFactory sessionFactory;
public SessionFactory getSessionFactory() {
return sessionFactory;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
继承JdbcDaoSupport。
UserDaoImpl extends JdbcDaoSupport
方法2、
UserDaoImpl extends HibernateDaoSupport
用JdbcTempalte或HibernateTempalte操作数据库。
本文详细解析了Spring框架中SessionFactory配置错误的原因及解决方法,包括在UserDaoImpl中加入对应的set方法和get方法,以及继承JdbcDaoSupport或HibernateDaoSupport来操作数据库。同时介绍了使用JdbcTemplate或HibernateTemplate进行数据库操作的技巧。
5563

被折叠的 条评论
为什么被折叠?



