我该如何解决这个错误。使用rest assured & eclipse : 启动层初始化时出错java.lang.module.FindException:

How can I resolve this error. Using rest assured & eclipse :Error occurred during initialization of boot layer java.lang.module.FindException:

我是使用rest assured 和eclipse 进行api 自动化测试的初学者。 我收到一个错误,我不知道如何解决它。

这里是错误:

引导层初始化出错 java.lang.module.FindException:未找到模块 restAssuredNewProject

我也在用maven。 我的日食版本是: 版本:2021-06 (4.20.0) 内部版本号:20210612-2011

Java 版本是: C:\Users\rally>java -版本 java 版本“1.7.0_80” Java(TM) SE 运行时环境(build 1.7.0_80-b15) Java HotSpot(TM) 64 位服务器 VM(构建 24.80-b11,混合模式)

这是我的代码:

import static io.restassured.RestAssured.*;
import io.restassured.RestAssured;
public class Basics {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        //Validate if Add Place api is working properly
        //given-all input details
        //when-Submit the api(resource , http methods)
        //Then-Validate the response
        RestAssured.baseURI= "https://rahulshettyacademy.com";
        given().log().all().queryParam("key", "qaclick123").header("Content-type","application/json")
        .body("{\r\n"
                + "  \"location\": {\r\n"
                + "    \"lat\": -38.383494,\r\n"
                + "    \"lng\": 33.427362\r\n"
                + "  },\r\n"
                + "  \"accuracy\": 50,\r\n"
                + "  \"name\": \"Frontline house\",\r\n"
                + "  \"phone_number\": \"(+91) 983 893 3937\",\r\n"
                + "  \"address\": \"29, side layout, cohen 09\",\r\n"
                + "  \"types\": [\r\n"
                + "    \"shoe park\",\r\n"
                + "    \"shop\"\r\n"
                + "  ],\r\n"
                + "  \"website\": \"http://google.com\",\r\n"
                + "  \"language\": \"French-IN\"\r\n"
                + "}\r\n"
                + "").when().post("maps/api/place/add/json")
        .then().log().all().assertThat().statusCode(200);

    }

}

这里是 pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>RestAssuredNewProject</groupId>
  <artifactId>RestAssuredNewProject</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <release>16</release>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
  <!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>4.4.0</version>
   </dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>7.4.0</version>
    </dependency>
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
<dependency>
    <groupId>org.hamcrest</groupId>
    <artifactId>hamcrest-all</artifactId>
    <version>1.3</version>
    </dependency>
</dependencies>
</project>

这是模块-info.java:

module restAssuredNewProject {
    requires rest.assured;
    requires hamcrest.library;
    requires org.hamcrest;
}

这里也有一些错误: 一个是“自动模块的名称 rest.assured 是 unstable.It 是从模块的文件名派生的。” 第二个错误“hamcrest 库无法解析为模块”...

快速修复是从命令行删除文件 module-info.java,然后 运行 mvn clean test-compile