spring配置文件的注入问题
求解:
这样写的时候没有错
XML code
<bean id="organuserServices"
class="com.dianxue.services.impl.OrganuserServices">
<property name="entityDao">
<ref bean="organuserDAO"/>
</property>
</bean>
这样写报错了:
XML code
<bean id="organuserServices"
class="com.dianxue.services.impl.OrganuserServices">
<property name="entityDao">
<list>
<ref bean="organuserDAO"/>
</list>
</property>
</bean>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'organuserServices' defined in ServletContext resource [/WEB-INF/classes/dataAccessContext.xml]: Initialization of bean failed;
nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [com.core.DAO.EntityDao] for property 'entityDao'; nested exception is
java.lang.IllegalArgumentException: Cannot convert value of type [java.util.ArrayList] to required type [com.core.DAO.EntityDao] for property 'entityDao': no matching editors or conversion strategy found
------解决方案--------------------噢。。。看错了
<list>
<ref bean="organuserDAO"/>
</list>
这个就是List类型
------解决方案--------------------Java code
<bean id="organuserServices"
class="com.dianxue.services.impl.OrganuserServices">
<property name="entityDao">
<ref bean="organuserDAO"/>
</property>
<property name="第二个Dao">
<ref bean="第二个Dao"/>
</property>
</bean>
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------