JAXB未显示所有XMLElements

时间:2019-05-09 09:25:03

标签: java xml jaxb

我正在尝试使用JAXB创建XML文件以显示productCode,productGroup,tradedUnitEA和tradedUnitDUN,但文件中未显示第一个属性“ productCode”

我正在使用JAXB 2.2.11版

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
        "productCode",
        "productGroup",
        "tradedUnitEAN",
        "tradedUnitDUN"
})
public class Product {

    @XmlElement(name = "ProductCode", required = true)
    protected String productCode;
    @XmlElement(name = "ProductGroup", required = true)
    protected String productGroup;
    @XmlElement(name = "TradedUnitEAN", required = true)
    protected String tradedUnitEAN;
    @XmlElement(name = "TradedUnitDUN", required = true)
    protected String tradedUnitDUN;

    public Product() {
    }

    public Product(String productCode, String productGroup, String tradedUnitEAN, String tradedUnitDUN) {
        this.productCode = productCode;
        this.productGroup = productGroup;
        this.tradedUnitEAN = tradedUnitEAN;
        this.tradedUnitDUN = tradedUnitDUN;

    }

    /**
     * Gets the value of the productCode property.
     *
     * @return possible object is
     * {@link String }
     */
    public String getProductCode() {
        return productCode;
    }

    /**
     * Sets the value of the productCode property.
     *
     * @param value allowed object is
     *              {@link String }
     */
    public void setProductCode(String value) {
        this.productCode = value;
    }

    /**
     * Gets the value of the productGroup property.
     *
     * @return possible object is
     * {@link String }
     */
    public String getProductGroup() {
        return productGroup;
    }

    /**
     * Sets the value of the productGroup property.
     *
     * @param value allowed object is
     *              {@link String }
     */
    public void setProductGroup(String value) {
        this.productGroup = value;
    }

    /**
     * Gets the value of the tradedUnitEAN property.
     *
     * @return possible object is
     * {@link String }
     */
    public String getTradedUnitEAN() {
        return tradedUnitEAN;
    }

    /**
     * Sets the value of the tradedUnitEAN property.
     *
     * @param value allowed object is
     *              {@link String }
     */
    public void setTradedUnitEAN(String value) {
        this.tradedUnitEAN = value;
    }

    /**
     * Gets the value of the tradedUnitDUN property.
     *
     * @return possible object is
     * {@link String }
     */
    public String getTradedUnitDUN() {
        return tradedUnitDUN;
    }

    /**
     * Sets the value of the tradedUnitDUN property.
     *
     * @param value allowed object is
     *              {@link String }
     */
    public void setTradedUnitDUN(String value) {
        this.tradedUnitDUN = value;
    }

}

Here is the look of XML file without productCode

0 个答案:

没有答案
相关问题