繁体   English   中英

JAXB:注释类型XmlElement的属性名称未定义

[英]JAXB: The attribute name is undefined for the annotation type XmlElement

当我尝试为JAXB分配XmlElementname属性时,我在Eclipse中收到错误:

The attribute name is undefined for the annotation type XmlElement

我的模型类的示例:

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Components {

    Component component;

    @XmlElement(name = "component")  // error on this line
    public void setComponent(Component component) {
        this.component = component;
    }
}

我试图用这个答案

好吧,事实证明这是一个愚蠢的错误。 我是进口的

import com.sun.xml.internal.txw2.annotation.XmlElement;

代替

import javax.xml.bind.annotation.XmlElement;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM