无法访问Eclipse和Rest Assured中找不到的org.hamcrest.Matcher的org.hamcrest.Matcher类文件

时间:2018-07-26 19:22:40

标签: maven pom.xml rest-assured hamcrest

嗨,我是新手,请放心并尝试用BDD进行操作,为此,我在尝试运行时编写了脚本,但出现了下面提到的错误

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/akrishnan/eclipse-workspace/BehavDD/src/Test/behaviourDrivenTest.java:[4,27] package org.hamcrest does not exist
[ERROR] /C:/Users/akrishnan/eclipse-workspace/BehavDD/src/Test/behaviourDrivenTest.java:[5,27] package org.hamcrest does not exist
[ERROR] /C:/Users/akrishnan/eclipse-workspace/BehavDD/src/Test/behaviourDrivenTest.java:[23,63] cannot find symbol
  symbol:   method hasSize(int)
  location: class Test.behaviourDrivenTest
[ERROR] /C:/Users/akrishnan/eclipse-workspace/BehavDD/src/Test/behaviourDrivenTest.java:[22,29] cannot access org.hamcrest.Matcher
  class file for org.hamcrest.Matcher not found
[ERROR] /C:/Users/akrishnan/eclipse-workspace/BehavDD/src/Test/behaviourDrivenTest.java:[38,41] cannot find symbol
  symbol:   method equalTo(java.lang.String)
  location: class Test.behaviourDrivenTest
[ERROR] /C:/Users/akrishnan/eclipse-workspace/BehavDD/src/Test/behaviourDrivenTest.java:[53,28] cannot find symbol
  symbol:   method equalTo(java.lang.String)
  location: class Test.behaviourDrivenTest
[ERROR] /C:/Users/akrishnan/eclipse-workspace/BehavDD/src/Test/behaviourDrivenTest.java:[68,63] cannot find symbol
  symbol:   method hasSize(int)
  location: class Test.behaviourDrivenTest
[ERROR] /C:/Users/akrishnan/eclipse-workspace/BehavDD/src/Test/behaviourDrivenTest.java:[80,63] cannot find symbol
  symbol:   method hasSize(int)
  location: class Test.behaviourDrivenTest
[ERROR] /C:/Users/akrishnan/eclipse-workspace/BehavDD/src/Test/behaviourDrivenTest.java:[128,73] cannot find symbol
  symbol:   method equalTo(java.lang.String)
  location: class Test.behaviourDrivenTest
[ERROR] /C:/Users/akrishnan/eclipse-workspace/BehavDD/src/Test/behaviourDrivenTest.java:[149,63] cannot find symbol
  symbol:   method hasSize(int)
  location: class Test.behaviourDrivenTest
[INFO] 10 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

我也添加了Maven依赖项

<dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-library</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core -->
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <version>1.3</version>
        <scope>test</scope>

我不知道我在这里想念的是什么。甚至我尝试用外部jar设置Build路径,仍然没有用。

1 个答案:

答案 0 :(得分:0)

在我的情况下,我必须删除示波器,因为我也在scoupe测试中使用了它。