struts-config.xml中配置action <action path="/testAction" type="org.springframework.web.struts.DelegatingActionProxy" name="testForm" scope="request" parameter="action"  validate="true">
<forward name="search" path="/testAction.do?action=query" contextRelative="true"/>
</action>
spring的配置文件中
    <bean id="testDao"  class="com.test.dao.TestDAO" />
<bean id="testService" parent="baseService"
class="com.test.service.TestService">
<property name="testDao">
<ref bean="testDao" />
</property>
</bean>

<bean name="/testAction"
class="com.test.action.TestAction">
<property name="testService">
<ref bean="testService"/>
</property>
</bean>

解决方案 »

  1.   

    <bean id="daoTool" class="com.wootion.dao.impl.DaoToolImpl">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>=========================这是applicationContext.xml配置文件中的一段
     <bean name="/add"
    class="com.wootion.struts.action.AddAction" >

    <property name="sshservice">
    <ref bean="sshservice" />
    </property>

    </bean>=========================这是action-context.xml配置文件中的一段
    <bean id="sshservice" parent="SshDAOProxy">
    <property name="target">
    <bean
    class="com.wootion.services.impl.SshservicesImpl">
    <property name="daoTool">
    <ref bean="daoTool" />
    </property>
    </bean>
    </property>
    </bean>=========================这是bo-context.xml配置文件中的一段在struts中我这样配置:
    <plug-in
    className="org.springframework.web.struts.ContextLoaderPlugIn">
    <set-property property="contextConfigLocation"
    value="/WEB-INF/classes/configs/action-context.xml" />
    </plug-in>
    可是找不到sshservice这个bean
      

  2.   

    这样可以
    <plug-in
    className="org.springframework.web.struts.ContextLoaderPlugIn">
    <set-property property="contextConfigLocation"
    value="/WEB-INF/classes/configs/action-context.xml,/WEB-INF/classes/configs/applicationContext.xml,......" />
    </plug-in> 
    似乎也可以这样(这个不确定)
    <plug-in
    className="org.springframework.web.struts.ContextLoaderPlugIn">
    <set-property property="contextConfigLocation"
    value="/WEB-INF/classes/configs/*-context.xml" />
    </plug-in> 
      

  3.   

    applicationContext.xml
    中加入<import resource="action-context.xml" />
    <import resource="bo-context.xml" />
      

  4.   


    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sshservice' defined in ServletContext resource [/WEB-INF/classes/configs/bo-context.xml]: Cannot create inner bean 'com.wootion.services.impl.SshservicesImpl#8a6fc' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.wootion.services.impl.SshservicesImpl#8a6fc' defined in ServletContext resource [/WEB-INF/classes/configs/bo-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'daoTool' of bean class [com.wootion.services.impl.SshservicesImpl]: Bean property 'daoTool' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.wootion.services.impl.SshservicesImpl#8a6fc' defined in ServletContext resource [/WEB-INF/classes/configs/bo-context.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'daoTool' of bean class [com.wootion.services.impl.SshservicesImpl]: Bean property 'daoTool' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?org.springframework.beans.NotWritablePropertyException: Invalid property 'daoTool' of bean class [com.wootion.services.impl.SshservicesImpl]: Bean property 'daoTool' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?现在还是这一堆堆的错误!请问是怎么回事?到底错在哪里了?
      

  5.   

    提示说daoTool这个属性,没注入成功,说明配置文件找到了,但是你的属性注入有问题吧get/set方法设置了吗
      

  6.   

    问题已解决!谢谢各位!
    主要是由于在services中注入的对象名与配置中的名字不一致