SpringJUnit4ClassRunner class not found

前端 未结 7 787
长发绾君心
长发绾君心 2021-01-07 18:16

i am trying to create a unit test using SpringJUnit4ClassRunner but everytime i execute the test it says it cannot find SpringJUnit4ClassRunner using mvn install.

         


        
相关标签:
7条回答
  • 2021-01-07 18:38

    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
    
    0 讨论(0)
  • 2021-01-07 18:39

    Go to pom.xml and make sure your file contain this dependency:

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

    Also make sure that in this dependency is no "scope" node:

    <scope>test</scope>
    
    0 讨论(0)
  • 2021-01-07 18:42

    FYI, Add this in your pom.xml

     <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    
    0 讨论(0)
  • 2021-01-07 18:42

    Maybe you lost the package

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>5.1.7.RELEASE</version>
    </dependency>
    
    0 讨论(0)
  • 2021-01-07 18:49

    I had to put sprint-test jar at the "TOP" of Java Build Path

    0 讨论(0)
  • 2021-01-07 18:52

    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

    0 讨论(0)
提交回复
热议问题