0
点赞
收藏
分享

微信扫一扫

json-schema-validator jar包冲突

项目中使用json-schema-validator库对json进行校验,同时引入了json-patch对schema进行patch,如果将json-schema-validator的mvn依赖放到json-patch的下面,就会出现jar包冲突的问题,从而报错。

如下:

<dependency>
<groupId>com.github.java-json-tools</groupId>
<artifactId>json-patch</artifactId>
<version>1.13</version>
</dependency>

<dependency>
<groupId>com.github.fge</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.2.6</version>
</dependency>

运行json-validator的校验方法

ProcessingReport report = JsonSchemaFactory.byDefault().getValidator()
.validateUnchecked(schemaJson, responseJson);

报如下错误: 

Exception in thread "main" java.lang.NoSuchMethodError: com.github.fge.jackson.JsonNumEquals.getInstance()Lcom/google/common/base/Equivalence;
at com.github.fge.jsonschema.core.keyword.syntax.checkers.common.EnumSyntaxChecker.<clinit>(EnumSyntaxChecker.java:46)
at com.github.fge.jsonschema.core.keyword.syntax.dictionaries.CommonSyntaxCheckerDictionary.<clinit>(CommonSyntaxCheckerDictionary.java:152)
at com.github.fge.jsonschema.core.keyword.syntax.dictionaries.DraftV3SyntaxCheckerDictionary.<clinit>(DraftV3SyntaxCheckerDictionary.java:55)
at com.github.fge.jsonschema.library.DraftV3Library.<clinit>(DraftV3Library.java:32)
at com.github.fge.jsonschema.cfg.ValidationConfigurationBuilder.<clinit>(ValidationConfigurationBuilder.java:63)
at com.github.fge.jsonschema.cfg.ValidationConfiguration.newBuilder(ValidationConfiguration.java:92)
at com.github.fge.jsonschema.cfg.ValidationConfiguration.byDefault(ValidationConfiguration.java:102)
at com.github.fge.jsonschema.main.JsonSchemaFactoryBuilder.<init>(JsonSchemaFactoryBuilder.java:68)
at com.github.fge.jsonschema.main.JsonSchemaFactory.newBuilder(JsonSchemaFactory.java:123)
at com.github.fge.jsonschema.main.JsonSchemaFactory.byDefault(JsonSchemaFactory.java:113)

经过mvn dependency检查,发现是由于jackson-coreutils冲突造成。解决方法,将json-path依赖放到json-schema-validator上面即可。


举报

相关推荐

0 条评论