3

我正在尝试使用http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_soap_rest/WEB-INF/beans中定义的 jaxrs:client 构建一个安静的客户端.xml

在我的测试类中,我得到 org.springframework.beans.factory.BeanCreationException: Error created bean with name 'com.abc.service.ExportServiceTest': 自动装配依赖注入失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException:无法自动装配字段:私有 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)}

这是我的春季配置

然而

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

这行得通。

谢谢喜芒树

4

1 回答 1

0

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

于 2012-09-20T20:31:08.483 回答