I had a problem while generating Java-Classes with JAXB under Java 1.6 where the @XmlRootElement
Annotation was not generated. In the Schema file I added the following block to force xjc to set the class name:
<xs:annotation>
<xs:appinfo>
<jaxb:class name="ClassName" />
</xs:appinfo>
</xs:annotation>
When i removed this block, the @XmlRootElement
Annotation was generated just like i wanted.
Did not find a solution on the internet for this problem but wanted to share it.
When generating classes from an XML Schema a JAXB implementation will generate a class annotated with @XmlRootElement
for each global element with an anonymous complex type. Global elements with a named complex type will have an @XmlElementDecl
annotation on a create
method on the generated ObjectFactory
class.
@XmlRootElement
is unrelated to the JAXB schema annotation you cite in your question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.