SpringJUnit4ClassRunner class not found

丶灬走出姿态 提交于 2019-12-01 02:14:22

I downloaded your code and got it working locally, as long as I included the relevant import statements:

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.junit.runner.RunWith;
import org.junit.Test;
...

Perhaps you're missing an import somewhere.

I fixed this one by

  • Deleting my local maven repo (~/.m2/repository) and
  • In eclipse forcing a new build (Project->Clean...)

Sourced from the appfuse forums

FYI, Add this in your pom.xml

 <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
</dependency>

If you are using linux, open the termial and work the command below. Do not forget to add the user in the place where the "user-name" is

cd /home/you-user/.m2/repository/ sudo rm -r junit

may be you lost the package

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-test</artifactId>
  <version>5.1.7.RELEASE</version>
</dependency>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!