How do I prevent JAXB from binding superclass methods of the @XmlRootElement when marshalling?

后端 未结 6 1845
谎友^
谎友^ 2020-12-30 09:10

I have a class that is annotated as the @XmlRootElement with @XmlAccessorType(XmlAccessType.NONE). The problem that I am having is that the superc

6条回答
  •  爱一瞬间的悲伤
    2020-12-30 09:58

    Just add

    @XmlAccessorType(XmlAccessType.NONE)
    

    in front of EACH superclass declaration (and the class itself).

    In your case:

    @XmlAccessorType(XmlAccessType.NONE)
    class NamedObject{
        [ ... ]
    }
    

    Remember that this has to be done really for each superclass, it is often forgotten when dealing with huge class dependency trees.

    Interfaces, of course, don't need any JAXB annotations.

提交回复
热议问题