Maven下org.junit.Test无法使用

原文地址:

https://blog.csdn.net/allenChenZhiMing/article/details/81412983

 

我在看Spring in action(第四版)的时候,看到了5.2.1测试控制器这一个部分的时候发现无法导入org.junit.Test和assertEquals。

代码的情况

就是这样子,查看了一下自己的pom.xml文件,发现这里的多了一行<scope>test</scope>

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
    <scope>test</scope> <!--这一行是多余的-->
</dependency>

将该行删去后即可

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
</dependency>

这下没有问题了

 

posted @ 2019-01-18 11:54  悠然现南山  阅读(1886)  评论(0编辑  收藏  举报