XmlJavaTypeAdapter not being detected

前端 未结 2 561
半阙折子戏
半阙折子戏 2020-12-06 02:27

Hopefully an easy one for JAXB experts:

I am trying to marshal an immutable class that does not define a default no-arg constructor. I have defined an

2条回答
  •  余生分开走
    2020-12-06 03:11

    I know that this is not the case, but if you have such an error when you put @XmlJavaTypeAdapter for the field - check that you specified the namespace. You may need it.

    In my case this didn't work:

    @XmlElement(name = "Expiration")
    @XmlJavaTypeAdapter(DateAdapter.class)
    private Date expiration;
    

    until a namespace has been specified:

    @XmlElement(name = "Expiration", namespace="http://site/your.namespace")
    @XmlJavaTypeAdapter(DateAdapter.class)
    private Date expiration;
    

提交回复
热议问题