🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 步骤 1. 导包:spring-test.jar , spring-aop.jar , junit.jar 2. 告诉spring-unit配置文件的位置. 3. 告诉spring-junit谁加载配置文件. 4. 调用junit. ## 注意 当我们使用spring5版本的时候需要Junit的版本是4.12以上. ~~~ //告诉spring配置文件位置 @ContextConfiguration(value = "classpath:applicationContext.xml") //使用XML的方式 @ContextConfiguration(classes= SpringConfig.class) //使用配置类的方式 //告诉spring谁来加载配置文件 @RunWith(value = SpringJUnit4ClassRunner.class) public class Test { @Autowired private UserService userService; @org.junit.Test public void test1() { userService.save(); } } ~~~