[请帮助我验证响应正文的架构。我遇到了运行时错误。:
线程“主”中的异常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>