JAXB propOrder标题案例标签不起作用

时间:2014-11-26 11:06:58

标签: java xml jaxb annotations

我需要在编组之后使用jaxb维护标记顺序,其中xml标记是标题大小写。 当试图将它投射到低于误差时。

"属性applicationCountFromDate存在但未在@ XmlType.propOrder中指定"

请在下面找到完整的堆栈和代码。

 
Property applicationCountFromDate is present but not specified in @XmlType.propOrder
    this problem is related to the following location:
        at public java.lang.String com.snapwork.bean.login.LoginRESBean.getApplicationCountFromDate()
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property applicationCountToDate is present but not specified in @XmlType.propOrder
    this problem is related to the following location:
        at public java.lang.String com.snapwork.bean.login.LoginRESBean.getApplicationCountToDate()
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property approvedApplicationCount is present but not specified in @XmlType.propOrder
    this problem is related to the following location:
        at public java.lang.String com.snapwork.bean.login.LoginRESBean.getApprovedApplicationCount()
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property declineApplicationCount is present but not specified in @XmlType.propOrder
    this problem is related to the following location:
        at public java.lang.String com.snapwork.bean.login.LoginRESBean.getDeclineApplicationCount()
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property displayName is present but not specified in @XmlType.propOrder
    this problem is related to the following location:
        at public java.lang.String com.snapwork.bean.login.LoginRESBean.getDisplayName()
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property operationErrorCode is present but not specified in @XmlType.propOrder
    this problem is related to the following location:
        at public java.lang.String com.snapwork.bean.login.LoginRESBean.getOperationErrorCode()
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property operationErrorMessage is present but not specified in @XmlType.propOrder
    this problem is related to the following location:
        at public java.lang.String com.snapwork.bean.login.LoginRESBean.getOperationErrorMessage()
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property operationStatus is present but not specified in @XmlType.propOrder
    this problem is related to the following location:
        at public java.lang.String com.snapwork.bean.login.LoginRESBean.getOperationStatus()
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property submittedApplicationCount is present but not specified in @XmlType.propOrder
    this problem is related to the following location:
        at public java.lang.String com.snapwork.bean.login.LoginRESBean.getSubmittedApplicationCount()
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property totalAppliationCount is present but not specified in @XmlType.propOrder
    this problem is related to the following location:
        at public java.lang.String com.snapwork.bean.login.LoginRESBean.getTotalAppliationCount()
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property OperationStatus appears in @XmlType.propOrder, but no such property exists. Maybe you meant operationStatus?
    this problem is related to the following location:
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property OperationErrorCode appears in @XmlType.propOrder, but no such property exists. Maybe you meant operationErrorCode?
    this problem is related to the following location:
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property OperationErrorMessage appears in @XmlType.propOrder, but no such property exists. Maybe you meant operationErrorMessage?
    this problem is related to the following location:
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property DisplayName appears in @XmlType.propOrder, but no such property exists. Maybe you meant displayName?
    this problem is related to the following location:
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property ApplicationCountFromDate appears in @XmlType.propOrder, but no such property exists. Maybe you meant applicationCountFromDate?
    this problem is related to the following location:
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property ApplicationCountToDate appears in @XmlType.propOrder, but no such property exists. Maybe you meant applicationCountToDate?
    this problem is related to the following location:
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property TotalAppliationCount appears in @XmlType.propOrder, but no such property exists. Maybe you meant totalAppliationCount?
    this problem is related to the following location:
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property ApprovedApplicationCount appears in @XmlType.propOrder, but no such property exists. Maybe you meant approvedApplicationCount?
    this problem is related to the following location:
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property SubmittedApplicationCount appears in @XmlType.propOrder, but no such property exists. Maybe you meant submittedApplicationCount?
    this problem is related to the following location:
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean
Property DeclineApplicationCount appears in @XmlType.propOrder, but no such property exists. Maybe you meant declineApplicationCount?
    this problem is related to the following location:
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean

代码:

 

import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlAccessType;
@XmlType (propOrder = {  "operationStatus",
        "operationErrorCode",
        "operationErrorMessage",
        "JSessionID",
        "DSACode",
        "displayName",
        "applicationCountToDate",
        "totalAppliationCount",
        "approvedApplicationCount",
        "submittedApplicationCount",
        "declineApplicationCount"
    })

public class LoginRESBean
{
    private String ApplicationCountToDate;

    private String TotalAppliationCount;

    private String ApplicationCountFromDate;

    private String DeclineApplicationCount;

    private String DSACode;

    private String SubmittedApplicationCount;

    private String ApprovedApplicationCount;

    private String DisplayName;

    private String OperationErrorMessage;

    private String OperationStatus;

    private String OperationErrorCode;

    private String JSessionID;

    @XmlElement (name = "ApplicationCountToDate")
    public String getApplicationCountToDate ()
    {
        return ApplicationCountToDate;
    }
    public void setApplicationCountToDate (String ApplicationCountToDate)
    {
        this.ApplicationCountToDate = ApplicationCountToDate;
    }

    @XmlElement (name = "TotalAppliationCount")
    public String getTotalAppliationCount ()
    {
        return TotalAppliationCount;
    }

    public void setTotalAppliationCount (String TotalAppliationCount)
    {
        this.TotalAppliationCount = TotalAppliationCount;
    }

    @XmlElement (name = "ApplicationCountFromDate")
    public String getApplicationCountFromDate ()
    {
        return ApplicationCountFromDate;
    }


    public void setApplicationCountFromDate (String ApplicationCountFromDate)
    {
        this.ApplicationCountFromDate = ApplicationCountFromDate;
    }

    @XmlElement (name = "DeclineApplicationCount")
    public String getDeclineApplicationCount ()
    {
        return DeclineApplicationCount;
    }


    public void setDeclineApplicationCount (String DeclineApplicationCount)
    {
        this.DeclineApplicationCount = DeclineApplicationCount;
    }

    @XmlElement (name = "DSACode")
    public String getDSACode ()
    {
        return DSACode;
    }

    public void setDSACode (String DSACode)
    {
        this.DSACode = DSACode;
    }

    @XmlElement (name = "SubmittedApplicationCount")
    public String getSubmittedApplicationCount ()
    {
        return SubmittedApplicationCount;
    }

    public void setSubmittedApplicationCount (String SubmittedApplicationCount)
    {
        this.SubmittedApplicationCount = SubmittedApplicationCount;
    }

    @XmlElement (name = "ApprovedApplicationCount")
    public String getApprovedApplicationCount ()
    {
        return ApprovedApplicationCount;
    }

    public void setApprovedApplicationCount (String ApprovedApplicationCount)
    {
        this.ApprovedApplicationCount = ApprovedApplicationCount;
    }

    @XmlElement (name = "DisplayName")
    public String getDisplayName ()
    {
        return DisplayName;
    }

    public void setDisplayName (String DisplayName)
    {
        this.DisplayName = DisplayName;
    }

    @XmlElement (name = "OperationErrorMessage")
    public String getOperationErrorMessage ()
    {
        return OperationErrorMessage;
    }

    public void setOperationErrorMessage (String OperationErrorMessage)
    {
        this.OperationErrorMessage = OperationErrorMessage;
    }

    @XmlElement (name = "OperationStatus")
    public String getOperationStatus ()
    {
        return OperationStatus;
    }

    public void setOperationStatus (String OperationStatus)
    {
        this.OperationStatus = OperationStatus;
    }

    @XmlElement (name = "OperationErrorCode")
    public String getOperationErrorCode ()
    {
        return OperationErrorCode;
    }

    public void setOperationErrorCode (String OperationErrorCode)
    {
        this.OperationErrorCode = OperationErrorCode;
    }

    @XmlElement (name = "JSessionID")
    public String getJSessionID ()
    {
        return JSessionID;
    }

    public void setJSessionID (String JSessionID)
    {
        this.JSessionID = JSessionID;
    }
}

import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlAccessType; @XmlType (propOrder = { "operationStatus", "operationErrorCode", "operationErrorMessage", "JSessionID", "DSACode", "displayName", "applicationCountToDate", "totalAppliationCount", "approvedApplicationCount", "submittedApplicationCount", "declineApplicationCount" }) public class LoginRESBean { private String ApplicationCountToDate; private String TotalAppliationCount; private String ApplicationCountFromDate; private String DeclineApplicationCount; private String DSACode; private String SubmittedApplicationCount; private String ApprovedApplicationCount; private String DisplayName; private String OperationErrorMessage; private String OperationStatus; private String OperationErrorCode; private String JSessionID; @XmlElement (name = "ApplicationCountToDate") public String getApplicationCountToDate () { return ApplicationCountToDate; } public void setApplicationCountToDate (String ApplicationCountToDate) { this.ApplicationCountToDate = ApplicationCountToDate; } @XmlElement (name = "TotalAppliationCount") public String getTotalAppliationCount () { return TotalAppliationCount; } public void setTotalAppliationCount (String TotalAppliationCount) { this.TotalAppliationCount = TotalAppliationCount; } @XmlElement (name = "ApplicationCountFromDate") public String getApplicationCountFromDate () { return ApplicationCountFromDate; } public void setApplicationCountFromDate (String ApplicationCountFromDate) { this.ApplicationCountFromDate = ApplicationCountFromDate; } @XmlElement (name = "DeclineApplicationCount") public String getDeclineApplicationCount () { return DeclineApplicationCount; } public void setDeclineApplicationCount (String DeclineApplicationCount) { this.DeclineApplicationCount = DeclineApplicationCount; } @XmlElement (name = "DSACode") public String getDSACode () { return DSACode; } public void setDSACode (String DSACode) { this.DSACode = DSACode; } @XmlElement (name = "SubmittedApplicationCount") public String getSubmittedApplicationCount () { return SubmittedApplicationCount; } public void setSubmittedApplicationCount (String SubmittedApplicationCount) { this.SubmittedApplicationCount = SubmittedApplicationCount; } @XmlElement (name = "ApprovedApplicationCount") public String getApprovedApplicationCount () { return ApprovedApplicationCount; } public void setApprovedApplicationCount (String ApprovedApplicationCount) { this.ApprovedApplicationCount = ApprovedApplicationCount; } @XmlElement (name = "DisplayName") public String getDisplayName () { return DisplayName; } public void setDisplayName (String DisplayName) { this.DisplayName = DisplayName; } @XmlElement (name = "OperationErrorMessage") public String getOperationErrorMessage () { return OperationErrorMessage; } public void setOperationErrorMessage (String OperationErrorMessage) { this.OperationErrorMessage = OperationErrorMessage; } @XmlElement (name = "OperationStatus") public String getOperationStatus () { return OperationStatus; } public void setOperationStatus (String OperationStatus) { this.OperationStatus = OperationStatus; } @XmlElement (name = "OperationErrorCode") public String getOperationErrorCode () { return OperationErrorCode; } public void setOperationErrorCode (String OperationErrorCode) { this.OperationErrorCode = OperationErrorCode; } @XmlElement (name = "JSessionID") public String getJSessionID () { return JSessionID; } public void setJSessionID (String JSessionID) { this.JSessionID = JSessionID; } }

2 个答案:

答案 0 :(得分:1)

属性名称来自getter / setter名称,而不是字段名称。

所以你必须写operationStatus,而不是OperationStatus

我不是百分百,总是如此,这可能取决于你是否注释了吸气剂或者字段本身。

答案 1 :(得分:1)

回答问题的原始版本

JAXB认为方法getApplicationCountToDate()对应于属性applicationCountToDate(请注意它以小写字母开头),因此期望applicationCountToDate中的propOrder没有ApplicationCountToDate。在这种情况下,你会得到一个非常好的例外,指出你正确的方向。

Property applicationCountToDate is present but not specified in @XmlType.propOrder
    this problem is related to the following location:
        at public java.lang.String com.snapwork.bean.login.LoginRESBean.getApplicationCountToDate()
        at com.snapwork.bean.login.LoginRESBean
        at public com.snapwork.bean.login.LoginRESBean com.snapwork.bean.login.LoginMBBean.getRS()
        at com.snapwork.bean.login.LoginMBBean

我在博客上写了更多关于propOrder的内容:


更新

使用更新后的模型,您将获得以下异常:

Property applicationCountFromDate is present but not specified in @XmlType.propOrder
    this problem is related to the following location:
        at public java.lang.String forum27147537.LoginRESBean.getApplicationCountFromDate()
        at forum27147537.LoginRESBean

我需要对您的问题中的更新代码执行的唯一操作是将applicationCountFromDate添加到propOrder以使一切正常运行:

@XmlType (propOrder = {"operationStatus",
        "operationErrorCode",
        "operationErrorMessage",
        "JSessionID",
        "DSACode",
        "displayName",
        "applicationCountToDate",
        "applicationCountFromDate",
        "totalAppliationCount",
        "approvedApplicationCount",
        "submittedApplicationCount",
        "declineApplicationCount"
})

public class LoginRESBean