bean class 属性 'dao' 无效的原因

Reasons of Invalid property 'dao' of bean class

在 applicationContext_dao 中我得到了 bean classNameDao,现在我正在尝试创建一个 BUS 层并添加到 applicationContext_bus 两个 bean。

<bean id="classNameValidator" class="cz.mikros.w4.model.bus.validator.ClassNameValidator">
        <property name="dao" ref="classNameDao" />
</bean>

<bean id="classNameBus" class="cz.mikros.w4.model.bus.impl.ClassNameBusImpl">
    <property name="dao" ref="classNameDao" />
    <property name="validator" ref="classNameValidator" />
</bean>

问题是

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'dao' of bean class [path.model.bus.validator.ClassNameValidator]: Bean property 'dao' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

你能告诉我问题出在哪里吗?

检查您的 path.model.bus.validator.ClassNameValidator 是否在 dao 上有 public setter 方法。应该叫public void setDao(DAO dao)