RestAssured_Class未找到_com / github / fge / jsonschema / main / JsonSchemaFactory

问题描述 投票:0回答:1

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

线程“主”中的异常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"));              

        }
}

请帮助解决错误。

java rest-assured
1个回答
0
投票

POM中是否包含以下内容?

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

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

enter image description here

<dependency>
    <groupId>com.github.java-json-tools</groupId>
    <artifactId>json-schema-validator</artifactId>
    <version>2.2.10</version>
</dependency>
© www.soinside.com 2019 - 2024. All rights reserved.