@RunWith(SpringJUnit4ClassRunner.class)
需要使用两个测试包
<!--测试包--><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>5.2.7.RELEASE</version></dependency><dependency><groupId>junit</groupId> <artifactId>junit</artifactId><version>4.13.1</version><scope>compile</scope></dependency>
不管你项目中导入的哪个版本的包,@Test和@RunWith两个注解导入用到的要是同一个包。
@ContextConfiguration(value = {“classpath:applicationConfig-dao.xml”,“classpath:applicationConfig-service.xml”})
注:这句话是将写好的xml文件加载(文件中包括session,数据源等待的Bean)。就不用手动加载xml了。