spring3mvc + hibernate3.5 :cry:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'userService' defined in file [F:\Tomcat 6.0\webapps\JframeCore\WEB-INF\classes\com\jframe\test\UserServiceImpl.class]: Initialization of bean failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionAdvice': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager';
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory';
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Error setting property values;
nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'packagesToScan' of bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Bean property 'packagesToScan' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'packagesToScan' of bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Bean property 'packagesToScan' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
看最后这个异常就很明显了,这个packagesToScan属性,没有set方法。
或者看下org.springframework.orm.hibernate3.LocalSessionFactoryBean有没这个packagesToScan属性,你是不是配置这个属性时把packagesToScan写错了
Bean property 'packagesToScan' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
说你的找个属性没有getter和setter方法
你肯定用了Annotation来配置hibernate映射吧,那么spring的sessionfactory就不能用localsessionfactorybean了,使用如下配置即可,
注意啊要用spring2.5
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
${hibernate.dialect}
true
true