项目是struts2+ibatis+spring的。

newsAction中有:
private NewsService newsService;
private NewsSortService newsSortService;在spring-action配置文件中配置了
<bean id="newsAction" class="action.NewsAction" scope="prototype">
       <property name="newsService"  ref="newsService"/>
       <property name="newsSortService"  ref="newsSortService"/>
</bean>
在spring-service:
<bean id="newsSortService" class="service.impl.NewsSortServiceImpl">
<property name="newsSortDao"  ref="newsSortDao"/>
</bean>
<bean id="newsService" class="service.impl.NewsServiceImpl">
<property name="newsDao"  ref="newsDao"/>
</bean>
在spring-dao中配置了
<bean id="newsSortDao" class="dao.impl.NewsSortDaoImpl">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
<bean id="newsDao" class="dao.impl.NewsDaoImpl">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>奇怪的是,我的newsSortService可以正常使用,而我一在spring-action中加入newsService,就会提示我无法在newsDao中注入sqlMapClient!但是我明明写进去了配置文件。上面的newsSortDao就能正常注入,怪了。报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'newsAction' defined in file [D:\Tomcat 6.0\webapps\ICED\WEB-INF\classes\applicationContext-action.xml]: Cannot resolve reference to bean 'newsService' while setting bean property 'newsService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'newsService' defined in file [D:\Tomcat 6.0\webapps\ICED\WEB-INF\classes\applicationContext-service.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlMapClient' is required

解决方案 »

  1.   

    newsAction
    你的这个Action配置错误了。
      

  2.   

    大哥,哪里配置错了啊?指教啊?<bean id="newsSortAction" class="action.NewsSortAction" scope="prototype">
           <property name="newsSortService"  ref="newsSortService"/>
        </bean>
        <bean id="newsAction" class="action.NewsAction" scope="prototype">
           <property name="newsService"  ref="newsService"/>
           <property name="newsSortService"  ref="newsSortService"/>
        </bean>  我spring-action中是这么配的,上面那个就没问题...
      

  3.   

    没见你配置这个啊 sqlMapClient
      

  4.   

    sqlMapClient已经配置了,这里没写上。
    我另一个newsSortDao就能正常的获得注入的sqlMapClient,下面那个却不行?
      

  5.   

    你类中的newsService   是不是跟配置文件里面名称是一样的?是那里面还需要注入 sqlMapClient 吧?
      

  6.   

    Error creating bean with name 'newsAction' defined in file [D:\Tomcat 6.0\webapps\ICED\WEB-INF\classes\applicationContext-action.xml]: 没找到这个 action啊?
      

  7.   

    sqlMapClient 这个在哪里配置的啊?
      

  8.   

    你的newsDao没有sqlMapClient属性以及相应的set方法
      

  9.   

    sqlMapClient这个bean没有配置,或者是配置到了其他文件里面,忘记加载这个文件了
      

  10.   

    Property 'sqlMapClient' is required newsDao里面有sqlMapClient的getter,setter?