首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JsonSchema2Pojo不知名属性不起作用

JsonSchema2Pojo不知名属性不起作用
EN

Stack Overflow用户
提问于 2017-12-15 00:16:38
回答 1查看 1.2K关注 0票数 1

我使用JsonSchema2Pojo将json转换为模型对象。它以预期的方式创建模型对象。但是,我也需要注释@JsonIgnoreProperties(ignoreUnknown = true)。这个JsonSchema2Pojo不可能有这个注释。但是,它似乎支持属性includeAdditionalProperties。即使在设置它之后,我也不会在生成的类中看到additionalPropertiesMap。这里有失踪的东西吗?

代码语言:javascript
复制
            <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>
EN

回答 1

Stack Overflow用户

发布于 2018-09-02 11:01:40

它可以通过使用自定义注解器来完成。

这里提供了示例实现和使用。

代码语言:javascript
复制
https://github.com/thewizardofjoz/jsonschema2pojo-ignoreunknown-annotator
https://github.com/thewizardofjoz/jsonschema2pojo-example
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47824074

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档