2016-05-02 149 views
5

我是RestAPI測試的新手。我正在嘗試使用Jsonschemavalidor。我添加了jar文件和所有依賴項。我仍然有以下錯誤。任何人都可以解決這個問題。java.lang.NoSuchFieldError:在通過json模式驗證器驗證json模式時拋出USE_DEFAULTS

Exception in thread "main" java.lang.NoSuchFieldError: USE_DEFAULTS 
    at com.fasterxml.jackson.annotation.JsonInclude$Value.<clinit>(JsonInclude.java:205) 
    at com.fasterxml.jackson.databind.cfg.MapperConfig.<clinit>(MapperConfig.java:45) 
    at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:543) 
    at com.fasterxml.jackson.databind.ObjectMapper.<init>(ObjectMapper.java:460) 
    at com.github.fge.jackson.JacksonUtils.newMapper(JacksonUtils.java:155) 
    at com.github.fge.jackson.JacksonUtils.<clinit>(JacksonUtils.java:55) 
    at com.github.fge.jackson.JsonNodeReader.<init>(JsonNodeReader.java:82) 
    at com.github.fge.jackson.JsonLoader.<clinit>(JsonLoader.java:50) 
    at com.jayway.restassured.module.jsv.JsonSchemaValidator$4.createJsonNodeInstance(JsonSchemaValidator.java:164) 
    at com.jayway.restassured.module.jsv.JsonSchemaValidator$4.createJsonNodeInstance(JsonSchemaValidator.java:161) 
    at com.jayway.restassured.module.jsv.JsonSchemaValidator$JsonSchemaValidatorFactory.create(JsonSchemaValidator.java:254) 
    at com.jayway.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchema(JsonSchemaValidator.java:161) 
    at com.jayway.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath(JsonSchemaValidator.java:117) 
    at com.nasdaq.api.GenericLib.validateJsonSchema(GenericLib.java:441) 

回答

9

您是否添加了最新版本的jackson-annotations?在2.6中加入的USE_DEFAULTS枚舉常量:

enter image description here

+1

感謝,我加入了最新的和解決的問題。 – user3419588

+0

@ user3419588 - 如果您可以將此答案標記爲已接受,則可幫助其他人找到具有類似問題的解決方案。謝謝! –