Loading... ## 步骤 1. 导入SpringTest模块 2. @ContextConfiguration注解指定Spring配置文件的位置 自动创建IOC容器 3. @RunWith指定spring单元测试模块 4. 直接使用@Autowired或@Resource注解注入需要测试的组件 ##### 1.1 导入Spring-test jar包 下载地址: https://mvnrepository.com/artifact/org.springframework/spring-test maven: 在pom.xml中添加 ``` <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>4.2.4.RELEASE</version> </dependency> ``` ##### 1.2 @ContextConfiguration指定Spring配置文件的位置  ##### 1.3 直接使用@Autowired或@Resource注解注入组件  ##### 1.4编写测试代码  ##### 1.5运行测试一下  Last modification:April 22, 2021 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 1 感谢大佬投喂 啾咪~
One comment
滴!学生卡!打卡时间:上午10:15:05,请上车的乘客系好安全带~