1.应用程序的入口
main方法
2.junit单元测试中,没有main方法也能执行
junit就会判断当前测试类中哪些方法有@Test注解
junit就让有注解的方法执行
3.junit不会管我们是否使用了spring框架
4.当测试方法执行时,没有IOC容器,就算写@Autowried注解,也会产生空指针异常
解决方法:
Spring整合junit的配置
1.导入Spring整合junit的jar包
2.使用junit提供的一个注解把原有的main方法替换了,替换成spring提供的@Runwith
3.告知spring的运行器,spring和ioc创建是基于xml还是注解的,并且说明位置
基于注解的:@ContextConfiguration(classes = SpringConfiguration.class)
基于配置文件的:@ContextConfiguration(locations = “classpath:bean.xml”)