JAXB with Spring ORM for marshaling tutorial

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

Right mouse click on target/generated-sources and select “Build Path –> Use as Source Folder

JAXB Spring Marshalling Example

JAXB Spring Marshalling Example

Step 1: add spring-orm to use JAXB and spring-xml to use StringResult.

Step 2: The App class with marshaling logic. It is marshaling the “PersonRequest” that was generated in the previous tutorial from an XSD file using the “maven-jaxb2-plugin”.

Step 3: The Spring context class “applicationContext.xml

Output:

Q. How does it know how to map?
A. From the XSD generated Java classes with the JAXB annotations demonstrated in https://www.java-success.com/basic-jaxb-tutorial-with-maven-xsd-1/.

And


800+ Java Interview Q&As Menu

Learn by categories on the go...
Learn by categories such as FAQs – Core Java, Key Area – Low Latency, Core Java – Java 8, JEE – Microservices, Big Data – NoSQL, Architecture – Distributed, Big Data – Spark, etc. Some posts belong to multiple categories.
Top