4

我试图找到解决方案,但仍然没有运气。

我正在关注“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+space) 时,它没有 packagesToScan 属性。在此处输入图像描述

我错过了什么?

4

1 回答 1

11

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

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

于 2012-06-03T18:13:21.900 回答