我在使用 schemagen 自动生成 XSD 文件时有点挣扎。首先,我必须告诉我,我正在为大学的一个项目工作,并且不能更改我的 java 类代码中的任何内容,但注释...
所以,基本上我要做的就是重命名我的一些 XmlElements 并且必须将它们带入特定的顺序。我想,我可以这样解决:
@XmlType(propOrder = { "email", "id", "name", "publication" })
public class Author {
...
private List<Publication> publications = new LinkedList<>();
...
@XmlElement(name = "publication")
public List<Publication> getPublications() {
return publications;
}
public void setPublications(List<Publication> publications) {
this.publications = publications;
}
XmlAccessorType 的默认值为@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
. 但是,当我尝试使用 schemagen(在 Eclipse 和命令行中)生成 XML Schema 时,出现以下错误:
Property publications is present but not specified in @XmlType.propOrder
和
Property publication appears in @XmlType.propOrder, but no such property exists. Maybe you meant publications?
所以,对我来说,这听起来有点矛盾,因为似乎 schemagen 完全忽略了我指定的内容......谁能告诉我问题出在哪里?
非常感谢!