我使用JsonSchema2Pojo将json转换为模型对象。它以预期的方式创建模型对象。但是,我也需要注释@JsonIgnoreProperties(ignoreUnknown = true)。这个JsonSchema2Pojo不可能有这个注释。但是,它似乎支持属性includeAdditionalProperties。即使在设置它之后,我也不会在生成的类中看到additionalPropertiesMap。这里有失踪的东西吗?
<plugin>
<groupId>org.jsonschema2pojo</groupId>
<artifactId>jsonschema2pojo-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<sourceDirectory>${project.parent.basedir}/app-service/src/main/resources/schema</sourceDirectory>
<targetPackage>com.xyz.test.dto</targetPackage>
<annotationStyle>jackson2</annotationStyle>
<generateBuilders>true</generateBuilders>
<useCommonsLang3>true</useCommonsLang3>
<useLongIntegers>false</useLongIntegers>
<includeJsr303Annotations>true</includeJsr303Annotations>
<includeAdditionalProperties>false</includeAdditionalProperties>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>发布于 2018-09-02 11:01:40
它可以通过使用自定义注解器来完成。
这里提供了示例实现和使用。
https://github.com/thewizardofjoz/jsonschema2pojo-ignoreunknown-annotator
https://github.com/thewizardofjoz/jsonschema2pojo-examplehttps://stackoverflow.com/questions/47824074
复制相似问题