将Lombok与@XmlElement一起使用 [英] Use lombok with @XmlElement

查看:770
本文介绍了将Lombok与@XmlElement一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Lombok与我的@XmlElement标签一起使用,以便可以解组对象?

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

我大约有20个属性,因此我希望不为每个带有setter上的XmlElement标记的吸气剂和setter写一个显式的吸气剂和setter.

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.

推荐答案

这可以完成工作:

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

这篇关于将Lombok与@XmlElement一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆