本帖最后由 insert_viann 于 2011-10-11 15:14:37 编辑

解决方案 »

  1.   

    我是需要加list的,因为我想给那个属性注入两个dao的
      

  2.   

    Cannot convert value of type [java.util.ArrayList] to required type [com.core.DAO.EntityDao] for property 'entityDao'
    类型转换异常 organuserDAO这个BEAN是ArrayList?
      

  3.   


    <bean id="organuserDAO" class="com.dianxue.dao.impl.OrganuserDAO"
                  <property name="sqlMapClient" ref="sqlMapClient" />
    </bean>
    这就是那个bean  bean怎么会是ArrayList类型呢  
      

  4.   

    setEntityDao参数呢 是什么类型
      

  5.   

    噢看错了
     <list>
                    <ref bean="organuserDAO"/>
                </list>
    这个就是List类型
      

  6.   


    <bean id="organuserServices"
            class="com.dianxue.services.impl.OrganuserServices">
            <property name="entityDao">
                 <ref bean="organuserDAO"/>
            </property>
            <property name="第二个Dao">
                 <ref bean="第二个Dao"/>
            </property>
        </bean>
      

  7.   


    public void setEntityDao(EntityDao entityDao) {
    this.entityDao = entityDao;
    }
    那是不是把setEntityDao的参数改成list呢
      

  8.   

    [Quote=引用 6 楼 zhongxingxuan 的回复:]
    可是我想把两个dao 都注入到 entityDao属性 中
      

  9.   

    查一个spring <list></list> 标签用法.....
      

  10.   


    可是把参数改成list的话, entityDao 就变成list类型了,就不能entityDao.selectByID 这样调用了
      

  11.   

    怎么安排都是逻辑上来说的,我只是说你如果要用<list></list>那你set的参数必须是List<>来匹配
    业务逻辑如果需要你用list 你就用List 然后需要用到的时候从List里面取出某个元素再调用方法
    如果逻辑上不是list你就不要用list了