Java setter的参数类型与getter的返回类型匹配吗?

Java setter的参数类型与getter的返回类型匹配吗?,java,spring,hibernate,spring-mvc,Java,Spring,Hibernate,Spring Mvc,我正在尝试学习如何使用DAO和BO类,我得到了以下错误 Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring/database/Hibernate.xml]: Error setting property valu

我正在尝试学习如何使用DAO和BO类,我得到了以下错误

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring/database/Hibernate.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?
Hibernate.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<!-- Hibernate session factory -->
<bean id="sessionFactory" 
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!--class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">-->
<property name="dataSource">
  <ref bean="dataSource"/>
</property>

<property name="configLocation">    
    <value>classpath:spring/database/hibernate.cfg.xml
    </value>
</property>

<property name="hibernateProperties">
   <props>
     <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
     <prop key="hibernate.show_sql">true</prop>
   </props>
</property>

    <property name="annotatedClasses">
<list>
    <value>com.fexco.helloworld.web.model.Customer</value>
    <value>com.fexco.helloworld.web.model.Countries</value>
</list>
</property>

</bean>

类路径:spring/database/hibernate.cfg.xml
org.hibernate.dialogue.sqlserverdialogue
真的
com.fexco.helloworld.web.model.Customer
com.fexco.helloworld.web.model.Countries

DataSource.xml

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<bean 
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
    <value>/properties/database.properties</value>
</property>
</bean>

<bean id="dataSource" 
     class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${database.driverClassName}" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
</bean>


 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="packagesToScan" value="data" />
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
            <prop key="hibernate.current_session_context_class">thread</prop>
            <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
        </props>
    </property>
</bean> 

/属性/database.properties
org.hibernate.dial.h2方言
线
org.hibernate.transaction.jdbc事务工厂
真的
更新

我不知道错误是从哪里来的,因为我的countries.java和customer.java类中的getter和setter方法都是正确的

有人知道出了什么问题吗?(如果您需要查看任何其他类,只需添加一条注释,说明哪些类,然后我会发布它们)


谢谢

看起来您想设置最初来自AnnotationSessionFactoryBean的“AnnotatedClass”属性,而实际上您使用的LocalSessionFactoryBean没有此属性

它实际上是在抱怨会话工厂的
annotatedClass
属性,你使用的是一个没有它的
LocalSessionFactoryBean
(你已经注释掉了有它的
AnnotationSessionFactoryBean
),早些时候,当它工作的时候,我正在摆弄它,改变了它,再也没有改变它回来。。。干杯:)