JAXB generating JAXBElement instead of String

后端 未结 4 1206
星月不相逢
星月不相逢 2020-12-13 18:21

I am using Apache CXF cxf-codegen-plugin Maven plugin to generate sources from WSDL file. Problem is that I get JAX

相关标签:
4条回答
  • 2020-12-13 18:49

    I think you want to add in your jaxb-binding.xml:

    <jaxb:bindings ... xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
        <jaxb:globalBindings generateElementProperty="false">
            <xjc:simple />
            <!-- ... -->
        </jaxb:globalBindings>
    </jaxb:bindings>
    
    0 讨论(0)
  • 2020-12-13 19:01

    What I had to do is to wrap jaxb:globalBindings with another jaxb:bindings.

    <jaxb:bindings version="2.0"
                   xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
        <jaxb:bindings>
            <jaxb:globalBindings generateElementProperty="false"/>
        </jaxb:bindings>
    </jaxb:bindings>
    

    Now everything is working, there is no JAXBElement<String> generated anymore.

    0 讨论(0)
  • 2020-12-13 19:01

    You can't have nillable and minoccurs together. Remove the minoccurs as it doesn't make sense for strings anyway.

    0 讨论(0)
  • 2020-12-13 19:15

    When we have both minouucrs=0 and nillable=true in XSD it will generate JAXBElement. To avoid this we need to remove either of the one.

    If you use generateElementProperty="false" property when generating POJO objects from XSD scheme then it will be working like a charm

    0 讨论(0)
提交回复
热议问题