部署应用程序时出现NotWritablePropertyException

时间:2015-01-05 06:36:14

标签: java spring hibernate

我在部署应用程序时遇到以下异常,是否有人知道这些工作?

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateUtil' defined in class path resource [spring-hibernate-cfg.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'sessionFactory' of bean class [com.library.database.HibernateUtil]: Bean property 'sessionFactory' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1493)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)

1 个答案:

答案 0 :(得分:1)

setSessionFactory();方法添加到com.go.database.HibernateUtil

你已经定义了属性sessionFactory并注入了HibernateUtil,Spring将使用setter注入,你没有这个属性的setter方法,所以它失败了