访问jaxrs中定义的bean:JUnit测试中Spring XML配置文件的serviceBeans部分?

时间:2015-07-28 15:01:31

标签: java spring jax-rs cxf

我正在尝试从集成测试中的以下Spring配置XML代码段访问MyBean

<jaxrs:server name="myResource" address="foo">
  <jaxrs:serviceBeans>        
    <bean id="myBean" class="com.example.bar.MyBean" />
  </jaxrs:serviceBeans>
  <jaxrs:providers>
    <!-- ... -->
  </jaxrs:providers>
</jaxrs:server>

我的测试看起来像这样:

@Resource(name = "myBean")
MyBean b;
//...

当我运行它时,我得到了

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.example.Test': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myBean' is defined

id添加到上面的bean没有帮助(之前我使用过@Autowired)。

如何从我的测试中的jaxrs:serviceBean部分访问该bean?

0 个答案:

没有答案