Invalid property 'annotatedClasses' of bean class
2017-04-05 09:28
537 查看
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?
错误代码:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.first.ssh.entity.User</value>
</list>
</property>
</bean>
annotatedClasses是在org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean里面。
org.springframework.orm.hibernate3.LocalSessionFactoryBean是用来做hibernate映射文件的读取mappingResources
在Hibernate Annotation Spring 整合的时候出现的:
解决方法:
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- results in a setDriverClassName(String) call -->
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="url" value="jdbc:jtds:sqlserver://localhost:1433;DatabaseName=db_ajax"/>
<property name="username" value="123"/>
<property name="password" value="123"/>
</bean>
<bean id="factory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.yin.hibernate.GuestBook</value>
</list>
</property>
</bean>
在 Hibernate distribution Spring整合时
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- results in a setDriverClassName(String) call -->
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="url" value="jdbc:jtds:sqlserver://localhost:1433;DatabaseName=db_ajax"/>
<property name="username" value="123"/>
<property name="password" value="123"/>
</bean>
<bean id="factory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/yin/hibernate/GuestBook.hbm.xml</value>
</list>
</property>
</bean>
上面只需要注意红色的部分就行了
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?
错误代码:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.first.ssh.entity.User</value>
</list>
</property>
</bean>
annotatedClasses是在org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean里面。
org.springframework.orm.hibernate3.LocalSessionFactoryBean是用来做hibernate映射文件的读取mappingResources
在Hibernate Annotation Spring 整合的时候出现的:
解决方法:
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- results in a setDriverClassName(String) call -->
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="url" value="jdbc:jtds:sqlserver://localhost:1433;DatabaseName=db_ajax"/>
<property name="username" value="123"/>
<property name="password" value="123"/>
</bean>
<bean id="factory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.yin.hibernate.GuestBook</value>
</list>
</property>
</bean>
在 Hibernate distribution Spring整合时
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- results in a setDriverClassName(String) call -->
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="url" value="jdbc:jtds:sqlserver://localhost:1433;DatabaseName=db_ajax"/>
<property name="username" value="123"/>
<property name="password" value="123"/>
</bean>
<bean id="factory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/yin/hibernate/GuestBook.hbm.xml</value>
</list>
</property>
</bean>
上面只需要注意红色的部分就行了
相关文章推荐
- Invalid property 'annotatedClasses' of bean class
- Invalid property 'annotatedClasses' of bean class
- org.springframework.beans.NotWritablePropertyException: Invalid property 'userDao' of bean class [co
- org.springframework.beans.NotWritablePropertyException: Invalid property 'userDao' of bean class
- Invalid property 'maxActive' of bean class [redis.clients.jedis.JedisPoolConfig]: Bean property
- Bean property 'annotatedClasses' is not writable or has an invalid setter method
- Invalid property 'name' of bean class
- Dubbo admin在JDK1.8环境运行报Invalid property 'URIType' of bean class
- spring boot 报错 Invalid property 'mapperHelper' of bean class [org.mybatis.spring.mapper.MapperFactor
- Invalid property 'driverClassName' of bean class
- Invalid property 'LyMhXnyjjsrDaoImpl' of bean class
- Dubbo admin在JDK1.8环境运行报Invalid property 'URIType' of bean class
- ssh 中使用c3p0 的连接池配置出错 Invalid property 'xxx' of bean class [com.mchange.v2.c3p0.ComboPoo
- Invalid property 'maxActive' of bean class [redis.clients.jedis.JedisPoolConfig]
- Invalid property 'maxActive' of bean class [redis.clients.jedis.JedisPoolConfig]
- org.springframework.beans.NotWritablePropertyException: Invalid property 'dDuMapDao' of bean class
- Invalid property 'maxActive' of bean class [redis.clients.jedis.JedisPoolConfig]: Bean property
- NotReadablePropertyException: Invalid property 'principal.userName' of bean class [org.springframewo
- tomcat启动报错:Invalid property 'userService' of bean class [xxxx]: No property 'xxx' found
- Tried to assign property OutStationNo:java.lang.Integer to bean of class