1. 程式人生 > >Maven專案中引入spring-test單元測試 @RunWith與@ContextConfigration報錯

Maven專案中引入spring-test單元測試 @RunWith與@ContextConfigration報錯

場景

在SSM專案整合時引入spring-test單元測試時,

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

報錯。

pom.xml中引入依賴如下

此依賴是從Maven中央倉庫直接複製過來的

解決

將pom.xml中的spring-test的依賴中的<scope>去掉