JAXB doesn't unmarshall after updating java from 1.8.0_77 to 1.8.0_121

后端 未结 4 534
遇见更好的自我
遇见更好的自我 2021-01-06 05:42

Yesterday I updated java like posted in the title, now JAXB doesn\'t parse xml anymore. All objects are simply null, nothing seems to be set.

Given this POJO - List

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-06 06:36

    Java8 newer version is more strict, I had same issue and found, we have to specify namespace for each field as follow to validate It worked for me

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "ListMatchingProductsResponse", propOrder = {
            "listMatchingProductsResult",
            "responseMetadata"
    })
    @XmlRootElement(name = "ListMatchingProductsResponse", namespace="http://example.com/api)
    public class ListMatchingProductsResponse {
        @XmlElement(name = "ListMatchingProductsResult", namespace="http://example.com/api)
        private ListMatchingProductsResult listMatchingProductsResult;
        @XmlElement(name = "ResponseMetadata", namespace="http://example.com/api)
        private ResponseMetadata responseMetadata;
        @XmlAttribute(name = "xmlns", namespace="http://example.com/api)
        private String xmlns;
    

提交回复
热议问题