在解析json模式并将其转换为javapojo时,我得到了以下错误堆栈。
[错误]无法执行目标org.jsonschema2pojo:jsonschema2pojo-maven插件:0.4.13:生成(默认)在项目XXXXXXXXXXXXX上:目标组织的执行默认.jsonschema2pojo:jsonschema2pojo-maven插件:0.4.13:生成失败:尝试创建同一字段两次:XXXXXXX->[帮助1]org.apache.maven.lifecycle.LifecycleExecutionException:未能执行目标org.jsonschema2pojo:jsonschema2pojo-maven插件:0.4.13:生成(默认)项目XXXXXXXXXXXXX:目标执行默认org.jsonschema2pojo:jsonschema2pojo-maven插件:0.4.13:生成失败:尝试创建同一字段两次:XXXXXXX
下面是我正在使用的maven插件的详细信息。
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<sourceDirectory>${basedir}/src/main/resources/json-schema.json</sourceDirectory>
<outputDirectory>${basedir}/src/main/java</outputDirectory>
<targetPackage>example.json.gen</targetPackage>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
你能发布你试图解析的JSON模式吗?听起来你有一个重复的字段?
---更新---
根据您的评论,您需要编辑json模式,如下所示:
{
"type" : "object",
"extends" : {
"$ref" : "classA.json"
}
}
通过这种方式,您可以从另一个json模式进行扩展。然而,如果有两个生成的json模式具有相同的字段,那么如果不手动编辑或自动删除重复的字段,就无法"合并"它们。