Use lombok with @XmlElement

MiketheCalamity picture MiketheCalamity · Aug 7, 2015 · Viewed 7.3k times · Source

How can I use Lombok in conjunction with my @XmlElement tags so that I can unmarshall the object?

I have about 20 properties, so I'm looking to not write an explicit getter and setter for each with the XmlElement tags on the setters.

Answer

MiketheCalamity picture MiketheCalamity · Oct 31, 2017

This gets the job done:

@Data
@XmlRootElement(name = "root")
@XmlAccessorType(XmlAccessType.FIELD)      // UPDATE: Need this or else exception
public class Data {
    @XmlElement(name = "test")
    public double testData;
}