我在版本0.12.3中使用org.jvnet.jaxb2.maven2:maven-jaxb2-plugin
,
我有以下问题。
我从xsd文件生成一个java文件。
我提交并将其推送到我们的git存储库。
我再次启动同一代(我们使用removeOldOutput
选项)。
对于某些文件,git检测到一些更改,因为某些注释的顺序在2代之间不一样。
第一代的一部分:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Software", propOrder = {
"rest"
})
public abstract class Software
extends SoftwareResource
implements Serializable
{
private final static long serialVersionUID = 1L;
@XmlElementRefs({
@XmlElementRef(name = "resource", type = JAXBElement.class),
@XmlElementRef(name = "software", type = JAXBElement.class),
@XmlElementRef(name = "swapSpaceUsedCurrent", type = JAXBElement.class),
@XmlElementRef(name = "isUTCTime", type = JAXBElement.class),
@XmlElementRef(name = "lastStartTime", type = JAXBElement.class),
@XmlElementRef(name = "serialNumber", type = JAXBElement.class),
@XmlElementRef(name = "numberProcessesActiveCurrent", type = JAXBElement.class),
@XmlElementRef(name = "pagingFileSizeCurrent", type = JAXBElement.class),
@XmlElementRef(name = "processMemorySizeCurrent", type = JAXBElement.class),
@XmlElementRef(name = "numUsersCurrent", type = JAXBElement.class)
})
protected List<JAXBElement<? extends Serializable>> rest;
/**
* Objects of the following type(s) are allowed in the list
* {@link JAXBElement }{@code <}{@link Resource }{@code >}
* {@link JAXBElement }{@code <}{@link BigInteger }{@code >}
* {@link JAXBElement }{@code <}{@link Software }{@code >}
* {@link JAXBElement }{@code <}{@link Boolean }{@code >}
* {@link JAXBElement }{@code <}{@link String }{@code >}
* {@link JAXBElement }{@code <}{@link BigInteger }{@code >}
* {@link JAXBElement }{@code <}{@link String }{@code >}
* {@link JAXBElement }{@code <}{@link Quantity }{@code >}
* {@link JAXBElement }{@code <}{@link BigInteger }{@code >}
* {@link JAXBElement }{@code <}{@link Quantity }{@code >}
*
*
*/
public List<JAXBElement<? extends Serializable>> getRest() {
if (rest == null) {
rest = new ArrayList<JAXBElement<? extends Serializable>>();
}
return this.rest;
}
}
第二代的同一部分:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Software", propOrder = {
"rest"
})
public abstract class Software
extends SoftwareResource
implements Serializable
{
private final static long serialVersionUID = 1L;
@XmlElementRefs({
@XmlElementRef(name = "numUsersCurrent", type = JAXBElement.class),
@XmlElementRef(name = "serialNumber", type = JAXBElement.class),
@XmlElementRef(name = "processMemorySizeCurrent", type = JAXBElement.class),
@XmlElementRef(name = "swapSpaceUsedCurrent", type = JAXBElement.class),
@XmlElementRef(name = "pagingFileSizeCurrent", type = JAXBElement.class),
@XmlElementRef(name = "lastStartTime", type = JAXBElement.class),
@XmlElementRef(name = "numberProcessesActiveCurrent", type = JAXBElement.class),
@XmlElementRef(name = "resource", type = JAXBElement.class),
@XmlElementRef(name = "isUTCTime", type = JAXBElement.class),
@XmlElementRef(name = "software", type = JAXBElement.class)
})
protected List<JAXBElement<? extends Serializable>> rest;
/**
* Objects of the following type(s) are allowed in the list
* {@link JAXBElement }{@code <}{@link BigInteger }{@code >}
* {@link JAXBElement }{@code <}{@link String }{@code >}
* {@link JAXBElement }{@code <}{@link Quantity }{@code >}
* {@link JAXBElement }{@code <}{@link String }{@code >}
* {@link JAXBElement }{@code <}{@link Quantity }{@code >}
* {@link JAXBElement }{@code <}{@link BigInteger }{@code >}
* {@link JAXBElement }{@code <}{@link BigInteger }{@code >}
* {@link JAXBElement }{@code <}{@link Boolean }{@code >}
* {@link JAXBElement }{@code <}{@link Resource }{@code >}
* {@link JAXBElement }{@code <}{@link Software }{@code >}
*
*
*/
public List<JAXBElement<? extends Serializable>> getRest() {
if (rest == null) {
rest = new ArrayList<JAXBElement<? extends Serializable>>();
}
return this.rest;
}
}
为什么这两个注释在两代之间的排序方式不同?有没有办法订购它们?
谢谢!
答案 0 :(得分:1)
此处maven-jaxb2-plugin
的作者。
首先,Aleksandr M是完全正确的。生成的代码通常不会检入SCM。整个target
目录与git
无关。
接下来,由maven-jaxb2-plugin
调用的JAXB模式编译器(XJC)不是确定性的,因此不保证生成的源代码在不同代码生成之间是相同的。这绝对不是maven-jaxb2-plugin
中的问题,我也不会将其称为XJC中的错误。只是降低您的期望,不要期望在运行之间使用相同的代码。