closertb的gravatar头像
closertb 2016-09-08 22:01:26
Spring配置出现“The name of the property, following JavaBean naming conventions.”错误提示

最近在学校SSH框架中的Spring;

基本套路就是Action调用Biz接口,Biz接口封装BIZIMPL对象,BIZIMPL调用DAO接口,DAO接口调用DAOIMPL对象,可是当配置statAciton的属性name="statBiz"时报错,提示“The name of the property, following JavaBean naming conventions”

Spring配置出现“The name of the property, following JavaBean naming conventions.”错误提示

        <!-- 定义StatDAOImpl类-->
    <bean id="statDAO" class="com.test.dao.impl.StatDAOImpl">      
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <!-- 定义StatBizImpl类,并为其statDAO属性注入值-->
    <bean id="statBiz" class="com.test.biz.impl.StatBizImpl">      
        <property name="statDAO" ref="statDAO" />
    </bean>

</bean>
    <!-- 定义StatAction,并为其中属性StatAction注入值 -->
    <bean name="statAction" class="com.test.action.StatAction" scope="prototype">
    <property name="statBiz" ref="statBiz" />     
    </bean>      

网上查了各种相关的,各种说法都有,有说申明顺序错误的,有说大小写的,但感觉都是在凭感觉解决问题,一点都不严谨,后来实在没法,自己看了下书。

原来是这样子的,当一个Action声明使用一个Biz接口对象,一般我们以为直接AAABiz aaaBiz一下就行,但忘了Spring最重要的一点依赖注入特性;所以我们需要给这个接口添加Set方法,用于依赖注入,具体为啥,自己看书。

所以在Action中我添加了一条:

    StatBiz statBiz;
    public void setStatBiz(StatBiz adminBiz) {
        this.statBiz = adminBiz;
    }    Spring配置出现“The name of the property, following JavaBean naming conventions.”错误提示


打赏
最近浏览
hahahaha9999ngt  LV1 2023年5月10日
1747499154  LV1 2022年4月14日
control system 2022年3月1日
暂无贡献等级
destiny233  LV1 2021年10月21日
drtao1 2021年6月30日
暂无贡献等级
zhangjiahao954  LV3 2021年5月24日
bb66666666 2020年10月17日
暂无贡献等级
最代码-宋家辉  LV61 2020年8月6日
45645651651  LV1 2020年7月16日
波波1554733592  LV6 2020年7月2日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友