Use lombok with @XmlElement

浪子不回头ぞ 提交于 2020-05-10 04:06:57

问题


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.


回答1:


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;
}


来源:https://stackoverflow.com/questions/31884406/use-lombok-with-xmlelement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!