JAXB inheritance, unmarshal to subclass of marshaled class

后端 未结 6 945
轮回少年
轮回少年 2020-11-30 21:36

I\'m using JAXB to read and write XML. What I want is to use a base JAXB class for marshalling and an inherited JAXB class for unmarshalling. This is to allow a sender Java

6条回答
  •  一向
    一向 (楼主)
    2020-11-30 22:04

    Since you really have two separate apps, compile them with different versions of the class "Person" - with the receiver app not having @XmlRootElement(name="person") on Person. Not only is this ugly, but it defeats the maintainability you wanted from using the same definition of Person for both sender and receiver. Its one redeeming feature is that it works.

提交回复
热议问题