# 解决：The import org.springframework.test.context.junit4.SpringJUnit4ClassRunner cannot be resolved

You need to add a dependency on spring-boot-starter-test:

<dependency><!--这里是spring-boot的解决办法-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
-
Thanks! this solved my problem. – Juan Carlos May 28 '15 at 17:49
I had to add also the version but worked also for me – Aditzu Sep 21 at 10:45
@aditzu If you are using Spring Boot, then adding the version should not be needed. – Wim Deblauwe Sep 21 at 13:32

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>

<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>

You need to add a dependency on spring-boot-starter-test:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
-
Thanks! this solved my problem. – Juan Carlos May 28 '15 at 17:49
I had to add also the version but worked also for me – Aditzu Sep 21 at 10:45
@aditzu If you are using Spring Boot, then adding the version should not be needed. – Wim Deblauwe Sep 21 at 13:32
You are right. For me which I'm not using Spring Boot, a dependency for "spring-test" was the solution. Thanks! – Aditzu Sep 21 at 13:56