import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.IOException;
@XmlRootElement
public class Person {
private String name;
private int age;
// Getters and setters
public static void main(String[] args) throws IOException {
// Create a person object
Person person = new Person();
person.setName("John");
person.setAge(30);
// Create ObjectMapper with JAXB annotations
ObjectMapper objectMapper = new ObjectMapper().setAnnotationIntrospector(new JaxbAnnotationIntrospector());
// Serialize person object to XML
String xml = objectMapper.writeValueAsString(person);
System.out.println(xml);
// Deserialize XML to person object
Person deserializedPerson = objectMapper.readValue(xml, Person.class);
System.out.println(deserializedPerson.getName());
System.out.println(deserializedPerson.getAge());
}
// Getters and setters
}