Jaxb, Class has two properties of the same name

Jaxb, Class has two properties of the same name

Asked on January 3, 2019 in XML.
Add Comment


  • 3 Answer(s)

    Try the below code:

    @XmlRootElement(name="yourRootElementName")
    @XmlAccessorType(XmlAccessType.FIELD)
    
    Answered on January 3, 2019.
    Add Comment

         It defined as,

                 the place where we use the “@XMLElement” annotation in the bean class.  

          The JAXB annotation processor consults the member field and  getter method of the same field element as various properties, when we use the @XMLElement annotation at the field level and throws the IllegalAnnotationExceptions exception.

    The exception message is that, class has two properties of the same name “timeSeries”. Instead of using @XmlElement in the field, use it in the getter method.

    In Getter Method :

    at public java.util.List testjaxp.ModeleREP.getTimeSeries()
    

    In Member Field :

    at protected java.util.List testjaxp.ModeleREP.timeSeries
    
    Answered on January 3, 2019.
    Add Comment

    Follow the below code for JAXB:

    @XmlAccessorType(XmlAccessType.FIELD)
    
    Answered on January 3, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.