简体   繁体   English

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

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

When I attempt to assign the name attribute for an XmlElement for JAXB, I get the error in Eclipse: 当我尝试为JAXB分配XmlElementname属性时,我在Eclipse中收到错误:

The attribute name is undefined for the annotation type XmlElement

Example of my model class: 我的模型类的示例:

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

    Component component;

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

I am attempting to use this answer . 我试图用这个答案

Okay, it turns out it was a dumb mistake. 好吧,事实证明这是一个愚蠢的错误。 I was importing 我是进口的

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

instead of 代替

import javax.xml.bind.annotation.XmlElement;

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

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