tomcate无法启动  我检查过了 引用都setter getter了  还是找不到问题  望高手请教Error creating bean with name 'studentAction' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'addservice' while setting bean property 'as'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'addservice' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy0 implementing Demo.Dao.Dao,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [Demo.Dao.StudentDao] for property 'sd'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy0 implementing Demo.Dao.Dao,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [Demo.Dao.StudentDao] for property 'sd': no matching editors or conversion strategy found

解决方案 »

  1.   

    studentAction中的addservice的实体类型和要被注入的实体类型不同.........Cannot resolve reference to bean 'addservice' while setting bean property 'as'...
      

  2.   

    Error creating bean with name 'studentAction' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'addservice' while setting bean property 'as'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'addservice' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: 
    看看配制文件。
      

  3.   

    1,看看你的实体类和配置文件有没有类型错误问题2,看看Struts配置文件中action的type是不是改成了org.springframework.web.struts.DelegatingActionProxy3,看看Spring配置文件中注入是否有错。一般都是这些问题,不是你再贴配置文件出来大家看看
      

  4.   

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.1.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.1.xsd">

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
    <property name="url" value="jdbc:mysql://localhost:3306/test"></property>
    <property name="username" value="root"></property>
    <property name="password" value=""></property>
    <property name="initialSize" value="5"></property>
    <property name="maxActive" value="20"></property>

    </bean> 


    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="mappingResources">
    <list>
    <value>
    Demo/Beans/Student.hbm.xml
    </value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    org.hibernate.dialect.MySQL5InnoDBDialect
    </prop>
    <prop key="hibernate.show_sql">
    true
    </prop>
    <prop key="hibernate.hbm2ddl.auto">
    update
    </prop>
    </props>
    </property>
    </bean>



    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
    <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <bean id="studentdao" class="Demo.Dao.StudentDao">
    <property name="hibernateTemplate" ref="hibernateTemplate"></property>
    </bean>
    <bean id="studentAction" class="Demo.Action.StudentAction">
    <property name="as" ref="addservice"></property>
    </bean>
    <bean id="delAction" class="Demo.Action.DelAction">
    <property name="ds" ref="delservice"></property>
    </bean>
    <bean id="addservice" class="Demo.Service.AddStudent">
    <property name="sd" ref="studentdao"></property>
    </bean>
    <bean id="delservice" class="Demo.Service.DelectStudent">
    <property name="sd" ref="studentdao"></property>
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <tx:advice id="daoTransactionAdvice">
    <tx:attributes>
    <tx:method name="save" isolation="DEFAULT" propagation="REQUIRED"/>
    <tx:method name="delByName" isolation="DEFAULT" propagation="REQUIRED"/>
    </tx:attributes>
    </tx:advice>

    <tx:advice id="serviceTransactionAdvice">
    <tx:attributes>
    <tx:method name="service" isolation="DEFAULT" propagation="REQUIRED"/>
    </tx:attributes>
    </tx:advice>
    <aop:config>
    <aop:pointcut id="daocut" expression="execution(* Demo.Dao.*.save(..))"/>
    <aop:pointcut id="servicecut" expression="execution(* Demo.Service.*.service(..))"/>
    <aop:advisor advice-ref="daoTransactionAdvice" pointcut-ref="daocut"/>
    <aop:advisor advice-ref="serviceTransactionAdvice" pointcut-ref="servicecut"/>
    </aop:config>

    </beans>
      

  5.   

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>
    MyDemo</display-name>
    <welcome-file-list>
    <welcome-file>add.jsp</welcome-file>
    </welcome-file-list> <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    </web-app>
      

  6.   

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>
    <constant name="struts.enable.DynamicMethodInvocation" value="flase"></constant>
    <constant name="struts.devMode" value="false"></constant>
    <constant name="struts.beanFactory" value="spring"></constant>

    <package name="default" namespace="/" extends="struts-default">

    <action name="studentAction" class="studentAction">
    <result name="success">success.jsp</result>
    </action>
    <action name="delAction" class="delAction">
    <result name="success">del.jsp</result>
    </action>

    </package></struts>
      

  7.   

    请问Demo.Service.AddStudent类里面的setter和getter方法是怎么写的?
      

  8.   

    addservice  这个bean  里面
    sd 这个属性对应的类不对 
    看下 bean 要求的是什么类 你传进去的又是什么类
      

  9.   

    Cannot convert value of type [$Proxy0 implementing Demo.Dao.Dao,org.springframework.beans.factory.InitializingBean,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [Demo.Dao.StudentDao] for property 'sd': no matching editors or conversion strategy found