没有自动连线

发布于 2024-10-09 07:37:27 字数 1141 浏览 0 评论 0原文

我正在尝试使用 http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_soap_rest/WEB-INF/beans。 xml

在我的测试类中,我收到 org.springframework.beans.factory.BeanCreationException: 创建名为 'com.abc.service.ExportServiceTest' 的 bean 时出错:自动装配依赖项注入失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException: 无法自动装配字段: private com.bankbazaar.service.ExportService com.abc.service.ExportServiceTest.exportClient;嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:找不到依赖项的 [com.abc.service.ExportService] 类型的匹配 bean:预计至少有 1 个有资格作为此依赖项的自动装配候选者的 bean。依赖注释: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=exportClient)}

这是我的 spring 配置

然而

    exportClient=(ExportService)applicationContext.getBean("exportClient");

这有效。

谢谢 希芒舒

I am trying to build a restful client using jaxrs:client as defined in http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml

In my test class I am getting org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.abc.service.ExportServiceTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bankbazaar.service.ExportService com.abc.service.ExportServiceTest.exportClient; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.abc.service.ExportService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=exportClient)}

this is my spring config

However

    exportClient=(ExportService)applicationContext.getBean("exportClient");

this works.

Thanks
Himangshu

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑看君怀她人 2024-10-16 07:37:27

两个 ExportService 的完全限定类名 com.abc.service.ExportServicecom.bankbazaar.service.ExportService 看起来不同。将两者修复为指向相同的名称应该可以解决问题。检查通过 applicationContext.getBean() 定义的 ExportService 的包名称以确定差异。

The fully qualified classname for the two ExportService looks different com.abc.service.ExportService vs com.bankbazaar.service.ExportService. Fixing the two to point to the same name should fix the problem. Check the package name of the ExportService defined via applicationContext.getBean() to acertain the difference.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文