[英]get all Beans of type in SpringJUnit4ClassRunner
我在为以下测试课程找到合适的答案时遇到问题:
@ContextConfiguration("classpath:services.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class RunnableServiceTest {
@Test
public void testConfiguration(){
Collection<Service> lAllService = >>getBeansOfType(Service.class)<<;
assertFalse(lAllService.isEmpty());
}
}
我想收集来自范围内的全部Spring管理豆context
services.xml
是类型Service
。
我很确定一定有这样的东西,但我不知道我要搜索什么。
非常感谢您的帮助。
斯特凡
您可以使用自动连线List
@ContextConfiguration("classpath:services.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class RunnableServiceTest {
@Autowired
private List<Service> lAllService;
@Test
public void testConfiguration(){
assertFalse(lAllService.isEmpty());
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.