Spring框架整合junit:包含配置文件的方式以及纯注解开发的方式
Spring框架合集:
Spring框架核心IOC的使用:IOC的作用+Bean管理+实例化Bean的方式+DI依赖注入
Spring框架核心IOC的使用:配置式开发+注解式开发+纯注解式开发
1. 准备工作
添加pom依赖
<!-- spring整合junit -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.0.2.RELEASE</version>
<scope>test</scope>
</dependency>
2. 配置文件的方式
如果不整合junit,那每次在测试类中都要加载配置文件,每次都要 new 一个 ClassPathXm