问答详情
源自:4-4 Action类交给Spring创建-Struts2整合Spring

org.springframework.beans.factory.BeanCreationException

ERROR [localhost-startStop-1] - Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productService' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'cn.muke.ssh.service.ProductService' to required type 'cn.muke.ssh.dao.ProductDao' for property 'productDao'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [cn.muke.ssh.service.ProductService] to required type [cn.muke.ssh.dao.ProductDao] for property 'productDao': no matching editors or conversion strategy found

 求大神回答这什么问题 万分感谢!

提问者:慕粉2314364488 2017-03-26 12:33

个回答

  • MihaiWong
    2017-04-08 17:50:59
    已采纳

    这个应该是bean的id名字的问题,注意字母大小写

    <!--配置action层  -->

    <bean id="productaction" class="com.action.ProductAction" scope="prototype">

    <property name="productservice" ref="productservice"></property>

    </bean>

    <!--配置service层  -->

    <bean id="productservice" class="com.service.ProductService">

    <property name="productdao" ref="productdao"></property>

    </bean>

    <!--配置dao层  -->

    <bean id="productdao" class="com.dao.ProductDao">

    </bean>