首页 文章

<jaxrs:client>未获得自动装配

提问于
浏览
3

我正在尝试使用jaxrs构建一个restful客户端: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用于依赖:预期至少有一个bean符合此依赖关系的autowire候选资格 . 依赖注释:{@ org.springframework.beans.factory.annotation.Autowired(required = true),@ org.springframework.beans.factory.annotation.Qualifier(value = exportClient)}

这是我的 Spring 季配置

然而

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

这很有效 .

谢谢Himangshu

1 回答

  • 0

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

相关问题