spring--Junit整合

Junit整合:
jar包:
5个基本包,加一个测试包:
spring-framework-3.2.0.RELEASE\libs-->spring-test-3.2.0.RELEASE.jar
@RunWith(SpringJUnit4ClassRunner.class)将spring和junit进行整合
@ContextConfiguration(locations="classpath:applicationContext.xml")加载classpath下的配置文件。
上面两个加注在类上,下面一个加注在类内部
@Autowired 整合后将service层进行自动注入,这样就不需要再进行xml的扫描了。
private UserService userService;

猜你喜欢

转载自jackpot1234.iteye.com/blog/2310372