我的问题与下面的帖子有关。How to add Jackson annotations to POJO generated from XSD by JAXB/XJC?有没有办法使用绑定文件为特定数据类型的所有元素添加注释?例如,使用@JsonFormat注释来注释所有'xs:time‘类型的元素,而不是单独为每个特定元素添加注释。
发布于 2018-06-01 03:55:13
谢谢你的词典。在绑定文件中添加以下内容就可以做到这一点。
<jaxb:bindings schemaLocation="Schema.xsd" node="//xs:element[@type='xs:date']" multiple="true">
<annox:annotate target="field">@com.fasterxml.jackson.annotation.JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone="GMT")</annox:annotate>
</jaxb:bindings>Xpath选择所有的'date‘元素,我们可以用一行注释它们。
https://stackoverflow.com/questions/50609777
复制相似问题