Java高级-Spring整合Junit测试

2020.6.27 9:17

@RunWith(SpringJunit4ClassRunner.class) //该注解表示会帮我们创建容器
@ContextConfiguration("classpath:applicationContext.xml") //指定的xml路径
public class test{
@Resource(name="user") //将名为user的对象注入到u变量中
public User u;

@Test
public void fun(){
	...
}
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章