我有一些问题要为下面的考试课找到一个合适的答案:
@ContextConfiguration("classpath:services.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class RunnableServiceTest {
@Test
public void testConfiguration(){
Collection<Service> lAllService = >>getBeansOfType(Service.class)<<;
assertFalse(lAllService.isEmpty());
}
}我想从有界的context services.xml收集属于Service类型的所有Spring托管bean。
我很确定一定有这样的东西,但我不知道我要寻找什么。
非常感谢你的帮助。
斯特凡
发布于 2015-11-25 09:49:10
你可以使用自动头发的List
@ContextConfiguration("classpath:services.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class RunnableServiceTest {
@Autowired
private List<Service> lAllService;
@Test
public void testConfiguration(){
assertFalse(lAllService.isEmpty());
}
}https://stackoverflow.com/questions/33913112
复制相似问题