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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With