JAXB rename attribute
问题 I have some class with a terrible long name, which is transformed into XML with JAXB. Using @XmlRootElement(name="nicername") , I am able to rename the outer XML tag to <nicername> . How do I rename individual attributes with ugly names of the class to some nice name too ? 回答1: You can use the @XmlAttribute and @XmlElement annotations to change the XML names. If you annotate the fields be sure to use the @XmlAccessorType(XmlAccessType.FIELD) annotation on the class: @XmlRootElement(name="nice