Search code examples
javaspringspring-mvcjacksonsap-commerce-cloud

How to use @JsonPropertyOrder annotation in beans.xml


I want to order my Data transfer object(POJO) created using beans.xml. can someone please tell me how to use @JsonPropertyOrder annotation in xml file rather than in Java?

Thanks much in advance


Solution

  • You can use the annotations element, like this:

    <bean class="de.hybris.platform.couponfacades.data.AnnotatedPojo">
    
        <import type="javax.xml.bind.annotation.XmlRootElement"/>
        <import type="javax.xml.bind.annotation.XmlElements"/>
        <import type="javax.xml.bind.annotation.XmlElement"/>
    
        <annotations>@XmlRootElement</annotations>
    
        <property name="someText" type="String">
    
            <annotations scope="getter">
            @XmlElements(value = {
                    @XmlElement(name="map",
                        type=ValueAsMap.class),
                    @XmlElement(name="string",
                        type=ValueAsString.class)
            })
            </annotations>
    
        </property>
    
    </bean>
    

    Other reference: