RestAssured_Class 不是 Found_com/github/fge/jsonschema/main/JsonSchemaFactory

RestAssured_Class Not Found_com/github/fge/jsonschema/main/JsonSchemaFactory

请帮助我验证响应正文的架构。我遇到运行时错误。:

Exception in thread "main" java.lang.NoClassDefFoundError: com/github/fge/jsonschema/main/JsonSchemaFactory

import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import io.restassured.response.ValidatableResponse;
import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
import static io.restassured.RestAssured.*;
public class Sample_JsonSchemaValidation {

        public static void main(String[] args) {
            // TODO Auto-generated method stub


            //ClassLoader loader = Sample_JsonSchemaValidation.class.getClassLoader();
            //System.out.println(loader.getResource("Sample_JsonSchemaValidation.class"));



    RestAssured.baseURI = "https://reqres.in/";             
                     given().contentType(ContentType.JSON).queryParam("id", 2).
                     when().get("api/users/").                   then().body(matchesJsonSchemaInClasspath("JsonSchemavalidator.json"));              

        }
}

请帮忙解决错误。

您的 POM 中是否包含以下内容?

<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>json-schema-validator</artifactId>
    <version>4.3.0</version>
</dependency>

编译依赖项包括 2 个工件,如果您没有它们,那么也将它们包含在您的 POM 中

<dependency>
    <groupId>com.github.java-json-tools</groupId>
    <artifactId>json-schema-validator</artifactId>
    <version>2.2.10</version>
</dependency>