场景

在SSM项目整合时引入spring-test单元测试时,

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:applicationContext.xml"})

报错。

Maven项目中引入spring-test单元测试 @RunWith与@ContextConfigration报错_spring

pom.xml中引入依赖如下

Maven项目中引入spring-test单元测试 @RunWith与@ContextConfigration报错_xml_02

此依赖是从Maven中央仓库直接复制过来的

Maven项目中引入spring-test单元测试 @RunWith与@ContextConfigration报错_xml_03

解决

将pom.xml中的spring-test的依赖中的<scope>去掉

Maven项目中引入spring-test单元测试 @RunWith与@ContextConfigration报错_spring_04