天天看點

Junit與spring的整合

在類上面加

@RunWith(springJunit4ClassRunner,class)

@ContextConfiguration(location={“classpath:檔案的位置”})

加了兩行注解後,就可以使用注入了

@Autowired

private DemoService demoService;

這樣就可以直接拿到service了

Junit與spring的整合