2015-01-05 37 views
0

當我部署應用程序時,Im得到下面的異常,有誰知道解決方法嗎?部署應用程序時NotWritablePropertyException

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

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

已定義的屬性sessionFactory並注入HibernateUtil,Spring將使用setter和你沒有setter方法此屬性,因此它失敗