org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceActionBean' defined in ServletContext resource [/WEB-INF/bean.xml]: Cannot resolve reference to bean 'serviceDao' while setting bean property 'serviceDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceDao' defined in ServletContext resource [/WEB-INF/bean.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'sessionFactory' of bean class [com.swu.dao.impl.ServiceDao]: 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?
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceDao' defined in ServletContext resource [/WEB-INF/bean.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'sessionFactory' of bean class [com.swu.dao.impl.ServiceDao]: 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?
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'sessionFactory' of bean class [com.swu.dao.impl.ServiceDao]: 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?
bean.xml
其他层代码:
------解决思路----------------------
Sping容器管理的bean,默认是单例的,那么在serviceAction 里面有一个共享属性Service,多线程访问的时候Service的属性就可能同时被多个线程修改,所以会破坏了数据的完整性
加上scope = 'prototype',就是原型模式,也就相当于每次调用的时候new一个对象了
另外sessionFactory的配置是怎样的
------解决思路----------------------
困扰我一个星期的问题终于解决了,的确是因为单例模式造成的,加上 scope='prototype' 属性之后就不会再报错了,7楼大神,谢谢了。
谢谢不给分吗? 哥是新手,还没得过分呢