spring整合JUnit测试

 1 //帮我们创建容器
 2 @RunWith(SpringJUnit4ClassRunner.class)
 3 //指定创建容器时使用的配置文件
 4 @ContextConfiguration("classpath:applicationContext.xml")
 5 public class TestDemo {
 6 
 7     // 将名为user的对象注入到一个变量中
 8     @Resource(name = "user")
 9     private User u;
10 
11     @Test
12     public void fun() {
13         System.out.println(u);
14     }
15 }

 

posted @ 2019-03-20 08:37  voidchar  阅读(352)  评论(0编辑  收藏  举报