91-9990449935 0120-4256464 |
Spring and JAXB Integration ExampleJAXB is an acronym for Java Architecture for XML Binding. It allows java developers to map Java class to XML representation. JAXB can be used to marshal java objects into XML and vice-versa. It is an OXM (Object XML Mapping) or O/M framework provided by Sun. Advantage of JAXBNo need to create or use a SAX or DOM parser and write callback methods.Example of Spring and JAXB Integration (Marshalling Java Object into XML)You need to create following files for marshalling java object into XML using Spring with JAXB:
Required Jar filesTo run this example, you need to load:
Employee.java If defines three properties id, name and salary. We have used following annotations in this class:
applicationContext.xml It defines a bean jaxbMarshallerBean where Employee class is bound with the OXM framework. Client.java It gets the instance of Marshaller from the applicationContext.xml file and calls the marshal method. Output of the exampleemployee.xml
download this example (developed using Myeclipse IDE)
download this example (developed using Eclipse IDE)
Next TopicSpring With Xstream Example
|