JAXB2 Annotations

This post explains some of frequently used JAXB2 annotations. For the complete list of JAXB2 annotations, please visit API Page Let’s quickly have a look of the mapped class, and the XML it will generate, then we will go through annotations, one at a time. Mapped Class Adapter class used in Mapped Class Generated XML…

Continue reading

JAXB2 Code Generation Maven Example

JAXB2 Code generation example using maven-jaxb2-plugin, adding generated code to source with build-helper-maven-plugin. Sometimes, while integrating with third party software, we only get XSD’s as input. In such situations, we are responsible to generate the actual JAXB compliant Java code which can then be used on client side to perform integration with third party. There…

Continue reading

JAXB2 Schema Validation Example

This post discusses about validating the generated XML against specific XML Schema Definition [XSD]. An XML Schema Definition describes the structure of an XML document and governs the rules and constraints being applied on XML content. JAXB provides API to validate the generated XML against an XSD in order to verify the correctness of generated…

Continue reading

JAXB2 Helloworld Example,Marshal/UnMarshal Example

This JAXB Helloworld Example post explains the basics of JAXB along with core concepts like Mapping, Marshalling and Unmarshalling XML to Java objects and vice versa, commonly used JAXB annotations, JAXBContext setup and API usage, XmlAdapter usage etc. Let’s go through them one by one: 1) Mapping Mapping refers to binding Java objects to XML…

Continue reading