简体   繁体   English

Jaxb API-删除JaxbElement

[英]Jaxb API - Remove JaxbElement

I have jaxb Class , in which when attribute is defined as below then value is loaded in list: 我有jaxb Class,其中当属性定义如下,然后值加载到列表中:

    @XmlElementRef(name = "mainElement", namespace = "http://www.xyz.org/spec/524/MODELS", type = JAXBElement.class)
   protected List<JAXBElement<? extends MainElement>> mainElement; 

when attribute is defined as below then value is not loaded in list(null contains) : 当属性定义如下时,则值不会加载到list(包含null)中:

    @XmlElement(name = "mainElement")
 protected List<MainElement> mainElement;

Is there a way to remove JAXBElement from java class generated from xsd . 有没有办法从xsd生成的java类中删除JAXBElement。

You can use xjc to generate your classes and if you don't like how they are generating you can change them using an bindings file. 您可以使用xjc生成类,如果您不喜欢它们的生成方式,则可以使用绑定文件进行更改。 See this stack question and answer for more info. 有关更多信息,请参见此堆栈问答。 jaxb xjc mapping jaxb xjc映射

Also, this blog is really helpful from Blaise Doughan. 另外,这个博客对Blaise Doughan真的很有帮助。 http://blog.bdoughan.com/ http://blog.bdoughan.com/

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

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