在使用Junit测试Hibernate+Spring时,提示如下异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'annotatedClasses' of bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Bean property 'annotatedClasses' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
原因是,在选择Session工程类时,选择的工厂类与PO映射方式不一致,Hibernate有两个Session工厂:
1、LocalSessionFactoryBean:通过XX.hbm.xml来映射实体类
2、AnnotationSessionFactoryBean:通过注释来映射实体类
选择第一种做Session工厂时,主要通过以下方式添加PO
<mapping resource="com/hibernate/News.hbm.xml"/>
选择第二种做Session工厂时,主要通过以下方式添加PO
<property name="annotatedClasses">
<list>
<value>com.test.entity.TPerson</value>
</list>
</property>
分享到:
相关推荐
Invalid property 'URIType' of bean class [com.alibaba.citrus.service.uribroker.uri.GenericURIBroker]: Bean property 'URIType' is not writable or has an invalid setter method. Does the parameter type ...
property 'URIType' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 这个问题我也在网上找了很久也没有好的解决方案,最后还是...
Invalid property 'error_view' of bean class [com.demo.controller.action.AuthorAction]: Bean property 'error_view' is not writable or has an invalid setter method. Does the parameter type of the ...
[com.alibaba.citrus.service.uribroker.uri.GenericURIBroker]: Bean property 'URIType' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of ...
Invalid property 'houseKeepingSleepTime' of bean class [org.logicalcobwebs.proxool.ProxoolDataSource]: Bean property 'houseKeepingSleepTime' is not writable or has an invalid setter method. Does the ...
dubbo-admin管理控制台安装... Invalid property 'URIType' of bean class [com.alibaba.citrus.service.uribroker.uri.GenericURIBroker]: Bean property 'URIType' is not writable or has an invalid setter method.
dubbo-admin 在jdk1.8 环境下会出现Bean property 'URIType' is not writable or has an invalid setter,此版本通过替换citris,spring的低版本解决了这个问题
org.springframework.beans....: Bean property 'transactionManagerBeanName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
property 'URIType' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 把其中的spring2的系列JAR包换成了spring3的,就可以在JDK8...
精通pl/sql part2
Storage Not Writable(解决方案).md
Directory Not Writable(解决方案).md
Backup Directory Not Writable(解决方案).md
Cache Directory Not Writable(解决方案).md
在某些情况下,内置的is_writable()函数可能无法正确地判断文件或目录的可写状态,比如在检查远程文件系统或某些特殊权限设置的情况下。这时,我们就可能需要自定义一个函数来模拟is_writable()的功能。 在给定的...
标题 "解决内存不能为read,write" 描述的是一个常见的计算机错误提示,通常在Windows操作系统中出现。这个错误表示程序在尝试访问内存时遇到了问题,可能是由于软件bug、硬件故障或者系统兼容性问题导致的。...
`is_writable()`会返回一个布尔值,如果文件存在且可写,那么返回`TRUE`,反之则返回`FALSE`。 ### 函数定义和语法 ```php bool is_writable ( string $filename ) ``` - `$filename`: 需要检查其可写性的文件或...