这个问题与JAXB2 type restriction not working?有关.我想扩展 XJC 以支持类型限制。它就像覆盖父类(super class)的字段定义一样简单。
有什么办法可以正确地做到这一点?有钩子(Hook)吗?有没有类似的工具?
最佳答案
是,XJC is extensible使用插件:
What can a plugin do?
A JAXB RI plugin participates in the code generation from a schema. It can define its own customizations that users can use to control it, it can access the code that the JAXB RI generates, and it can generate additional classes/methods/fields/annotations/comments.
A plugin can also choose to take over the XJC's code generation process completely. Only one plugin can do this at any given time, but this allows a plugin to generate radically different code from a schema.
另请参阅此答案:
What is the role of ClassOutline / JClass / CClass in CodeModel?
但不,我认为这不是解决 the problem 的正确方法你有。
尝试找出绑定(bind)或修补模式。
关于java - XJC - 它是可扩展的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26619375/