找不到类SpringRunner解决办法

找不到符号SpringRunner 解决办法

import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class Redisdemo2ApplicationTests {

    @Test
    public void contextLoads() {
    }
}

如上图所示,在运行项目的时候,这里会报错,一开始我也莫名其妙,网上找了各种解决方法,最后解决了,现在来汇总一下,首先是删除本地仓库下的Spring-test包,然后重新update一下项目,试过了,没用
我的解决方法是查看一下pom文件,找找test相关依赖

  		 <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version> 3.2.4.RELEASE  </version>
            <scope>provided</scope>
        </dependency>


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

这里看到了上面的依赖会有个版本号,将它去掉就可以了

如果能解决你的困扰,请为我点赞吧~谢谢大家!

相关文章: