JAXB XJC - 如何为 xsd simpleType 生成类
我正在尝试使用 Maven jaxb 插件从 xsd 模式开始生成 java 类。一切都很好。我只需要一个改进。 xsd 模式中的此类简单类型
<xs:simpleType name="Max350Text">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="350"/>
</xs:restriction>
</xs:simpleType>
由于 krasa-jaxb-tools 中的 -XJsr303Annotations 开关(由 fla 维护), 被映射为带有 Bean Validation 注释的 String 属性。 有没有办法从 simpleType 生成类而不是带有验证的属性? 由于我还需要从生成的 java 类生成 JSON 模式,因此我不希望对每个字符串属性进行内联限制,但我需要一个不同的 JSON 对象来定义所有其他引用属性的限制。
I'm trying to generate java classes using maven jaxb plugin starting from an xsd schema. Everything is fine. I need just a refinement.
Simple types like this in the xsd schema
<xs:simpleType name="Max350Text">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="350"/>
</xs:restriction>
</xs:simpleType>
are mapped as String properties with Bean Validation annotations thanks to the -XJsr303Annotations switch from krasa-jaxb-tools, mantained by fillumina.
Is there a way to generate Classes from simpleType instead of properties with validation?
Since I need to generate also JSON schema from the generated java classes I don't want in-line restrictions on every single string property but I need a distinct JSON object that defines restrictions for all other referencing ones.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论