一、问题描述
Springboot项目,使用单元测试,但是本地无法导入@RunWith注解。
然而,pom中又已经加载了
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
二、问题原因
后续通过参考资料,发现添加junit依赖即可。可能原因,是spring-boot-starter-test这个依赖在这个版本中没有junit,所以需要自己添加。
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
三、参考