【问题标题】:Reasons of Invalid property 'dao' of bean classbean 类的无效属性 'dao' 的原因
【发布时间】:2017-12-01 11:10:08
【问题描述】:

在 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>

问题是

原因:org.springframework.beans.NotWritablePropertyException:bean 类 [path.model.bus.validator.ClassNameValidator] 的无效属性“dao”:bean 属性“dao”不可写或具有无效的 setter方法。 setter的参数类型和getter的返回类型是否匹配?

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

【问题讨论】:

    标签: java spring dao


    【解决方案1】:

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

    【讨论】:

    • 是的,我有这个方法
    • 好的,你说得对,我的 getter 有问题,非常感谢
    猜你喜欢
    • 2013-12-12
    • 1970-01-01
    • 2019-09-24
    • 2018-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-26
    • 2015-10-21
    相关资源
    最近更新 更多