代码改变世界

JAXB 遇到的问题

2017-10-12 09:29  如是我所闻  阅读(427)  评论(0编辑  收藏  举报

抛出错误信息:1 counts of IllegalAnnotationExceptions Class has two properties of the same name "test"

  如果类上有@XmlAccessorType(XmlAccessType.FIELD)注解,@XmlElement(name="xxx")写在属性上。

@XmlElement(name="xxx")
private String test; 

  如果类上没有@XmlAccessorType(XmlAccessType.FIELD)注解,@XmlElement(name="xxx")写在get方法上

  @XmlElement(name="xxx")
    public String getTest() {
        return test;
    }