Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

xml

jaxb

When I attempt to assign the name attribute for an XmlElement for JAXB, I get the error in 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.

like image 884
Corey Wu Avatar asked Feb 13 '23 05:02

Corey Wu


1 Answers

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;
like image 89
Corey Wu Avatar answered Feb 15 '23 19:02

Corey Wu