问题
I'm trying to reuse classes that are already compiled and available. This looks to be achievable by declaring bindings to the pre-existing classes as per example bindings extract below:-
<jaxb:bindings schemaLocation="MyExample.xsd">
<jaxb:bindings node="//xs:simpleType[@name='MySimpleType']">
<jaxb:class ref="com.example.MySimpleType" />
</jaxb:bindings>
<jaxb:bindings node="//xs:complexType[@name='MyComplexType']">
<jaxb:class ref="com.example.MyComplexType" />
</jaxb:bindings>
</jaxb:bindings>
The problem is that whilst complex types work just fine, the simple types are ignored and still generated....
I've tried a variety of different notations (e.g. scd) with no success on the Simple Types.
Any ideas or help very welcome....
回答1:
If the generated class you are trying to reference is an enumeration (i.e. it implements javax.xml.bind.annotation.XmlEnum
), then you need to use:
jaxb:typesafeEnumClass
instead of
jaxb:class
in the bindings.
来源:https://stackoverflow.com/questions/15656803/class-reuse-with-jaxb-bindings-dont-honour-simpletypes