2012-06-03 148 views
4

我试图找到解决方案,但仍然没有运气。bean类的无效属性'packagesToScan'[org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]

我下面的书"Pro Spring 3"(Appress)[页351]

我已经生成的项目作为JPA项目。

据我所知,我可以使用persistence.xml或可以在bean内部管理它,这正是我想要的。

最新我们需要定义packagesToScan属性。

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaPersonService': Injection of persistence dependencies failed; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emf' defined in class path resource [META-INF/app-context.xml]: Error setting property values; nested exception 
is **org.springframework.beans.NotWritablePropertyException: Invalid property 'packagesToScan' of bean class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: 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? 

当我尝试询问建议(ctrl +空格)时,它没有packagesToScan属性。 enter image description here

我错过了什么?

回答

11

'packagesToScan'在Spring 3.1中添加了属性(比较3.03.1)。

确保您在CLASSPATH中包含最新的3.1 Spring JAR。

+0

更新了maven - works,很高兴不要创建额外的persistence.xml – Aubergine

相关问题