Reputation: 1159
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.
Upvotes: 4
Views: 4653
Reputation: 1159
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;
Upvotes: 8