简体   繁体   English

JAXB批注和超类

[英]JAXB Annotations and SuperClass

I'm trying to use JAXB annotations in a parent class so that all the sub classes can inherit them but I'm running into a marshaling error. 我试图在父类中使用JAXB批注,以便所有子类都可以继承它们,但是我遇到了封送处理错误。 I don't get the below error when I include @XmlRootElement and @XmlAccessorType(XmlAccessType.FIELD) in the sub class 当我在子类中包含@XmlRootElement和@XmlAccessorType(XmlAccessType.FIELD)时,我没有出现以下错误

error: HTTP Status 500 - Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: application/xml 错误:HTTP状态500-找不到类型为java.util.Array的响应对象的MessageBodyWriter,媒体类型为:application / xml

@MappedSuperclass
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Parent {

//class contents here
}

public class Child extends Parent{

//class contents here
}

您必须在父类的@XmlSeeAlso注释中列出所有子类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM