java - org.jvnet.jaxb2.maven2 :maven-jaxb2-plugin : same file , 倍数结果

标签 java git maven plugins maven-jaxb2-plugin

我正在使用版本0.12.3中的org.jvnet.jaxb2.maven2:maven-jaxb2-plugin, 我有以下问题。

  1. 我从 xsd 文件生成 java 文件。

  2. 我提交并将其推送到我们的 git 存储库中。

  3. 我再次启动同一代(我们使用 removeOldOutput 选项)。

  4. 对于某些文件,git 会检测到一些更改,因为某些注释的顺序在两代之间并不相同。

第一代的一部分:

@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;
    }

}

为什么两代之间的注释顺序不同?有办法订购吗?

谢谢!

最佳答案

这里是 maven-jaxb2-plugin 的作者。

首先,Aleksandr M 是完全正确的。生成的代码通常不会 checkin SCM。整个target目录与git无关。

接下来,由 maven-jaxb2-plugin 调用的 JAXB 模式编译器 (XJC) 不是确定性的,因此不能保证不同代码生成之间生成的源代码相同。这绝对不是 maven-jaxb2-plugin 中的问题,我也不会称其为 XJC 中的错误。只是降低您的期望,不要期望运行之间的代码相同。

关于java - org.jvnet.jaxb2.maven2 :maven-jaxb2-plugin : same file , 倍数结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28894025/

相关文章:

java - 通过本地pom禁用maven设置镜像

java - Hadoop 2.5.2 mvn 构建失败 Windows 7 x64 - hadoop-common 上的 compile-ms-native-dll?

java - Maven 默认语言环境与操作系统语言环境不同

java - Spring Data 1.11.7 没有属性存在

java - 如何避免 Fortify 中的误报 "Null Dereference"错误

git - 如何撤消 merge 请求及其提交?

git - 多个开发人员 push 相同的更改

java - Android:Restful WS 的结果未显示在我的 ListView 上

Java 颠覆库

git - 有没有办法删除 Ubuntu 20.04 中 Visual Studio Code 缓存的 GitHub 密码?