JAXB with Spring ORM for unmarshaling tutorial

This extends Basic JAXB tutorial with Maven & XSD – 1 to unmarshal with Spring OXM and Spring XML.

JAXB with Spring unmarshaling example

JAXB with Spring unmarshaling example

The Spring & JAXB marshaling tutorial used XML based config to inject the “jaxb2Marshaller”, but in this to make things a bit more interesting, let’s use “Java” class based Spring configuration with “@Configuration” to inject “jaxb2Marshaller“.

Step 1: For that, you need “spring-context” and “spring-context-support” in the pom.xml file.

Step 2: The App.java class.

Step 3: The Java class based Spring config to inject jaxb2Marshaller

Step 4: The Spring applicationContext.xml with component scan.

Step 5: Run the App.java.


Java Interview FAQs

800+ Java Interview Q&As

Top