SpringJunit4测试

前段时间工作中遇到了,所以就简单学习了一下,只学到了点皮毛,

1.测试类

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class SpringJunit4test
{
@Resource
Date date;
@Test
public void testas()
{
System.out.println(date.getTime());
}

@Autowired
ApplicationContext ctx;

@Test
public void testbb() throws Exception
{
DaoBean db = ctx.getBean(DaoBean.class);
db.show();
}

}

2.DaoBean 

 

3.XML配置

 

posted @ 2018-01-28 18:06  追梦少年_09  阅读(76)  评论(0编辑  收藏  举报