实施“ xml-元素”使用 MOXy
我想知道如何使用 EclipseLink MOXy 实现接口类型列表,
之前,使用 JAXB ,以下注释完成了
class A {
@XmlElements({
@XmlElement(name = "B1", type = B1.class),
@XmlElement(name = "B2", type = B2.class)
})
List< B > list;
}
interface B{}
class B1 implements B {}
class B2 implements B {}
支持接口类型列表的工作
???
I want to know how to implement having List of interface Type using EclipseLink MOXy,
Before, using JAXB , The following annotations did the job
class A {
@XmlElements({
@XmlElement(name = "B1", type = B1.class),
@XmlElement(name = "B2", type = B2.class)
})
List< B > list;
}
interface B{}
class B1 implements B {}
class B2 implements B {}
to support List of interface type ???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我领导 EclipseLink JAXB (MOXy)。我无法重现您的问题。您能提供您所看到的堆栈跟踪吗?以下是我尝试过的:
演示
jaxb.properties
input.xml
输出
使用 EclipseLink JAXB (MOXy) 的 XML 元数据文件
MOXy 还具有以 XML 文件形式提供元数据的扩展。下面是此示例的外观:
创建 JAXBContext 时,此元数据文件作为属性传入:
有关详细信息,请参阅:
I lead EclipseLink JAXB (MOXy). I am not able to reproduce your issue. Could you provide the stack trace you are seeing? The following is what I have tried:
Demo
jaxb.properties
input.xml
Output
Using EclipseLink JAXB (MOXy)'s XML Metadata File
MOXy also has an extension to provide the metadata as an XML file. Below is what it would look like for this example:
This metadata file is passed in as a property when the JAXBContext is created:
For more information see: