项目是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
在
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
解决方案 »
- 怎么使用JMockit来Mock一个接口 ?
- weblogic 部署整合spring的webservice项目 有问题 很急 求救!!!
- MyEclipse 2013 修改虚拟路径问题
- <html:form action="oxAction.do?forumID=取参数值代码"> 问题
- 精通EJB第三版(英文版)下载
- 如何将对象保存在字符串中
- 求助::我在jbuilderX中运行struts程序总是出一下错,请高手看看是什么问题? thanks.....
- 有人在使用Rational Rapid Developer开发程序吗?
- 请高手指点如何用visual age for java 3.x开发和调试ejb? 急急急!!!!
- org.springframework.beans.factory.NoSuchBeanDefinitionException 异常
- Java 银行家算法
- java 下载 中文文件名乱码的问题。。急。。。。
你的这个Action配置错误了。
<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中是这么配的,上面那个就没问题...
我另一个newsSortDao就能正常的获得注入的sqlMapClient,下面那个却不行?