JAXB, XJC -> create multiple class files

后端 未结 1 1668
情深已故
情深已故 2020-12-03 01:10

I\'m using JAXB and XJC for first time.

I would like to generate Java classes from XML file so I use this online helper to generate schema from XML file.

Aft

相关标签:
1条回答
  • 2020-12-03 01:59

    By default JAXB (JSR-222) will create static inner classes for nested complex types to prevent class name conflicts. You can use an external binding file to disable this behaviour.

    binding.xml

    A binding file allows you to customize how Java classes are generated from an XML schema.

    <jaxb:bindings
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
        version="2.1">
        <jaxb:globalBindings localScoping="toplevel"/>
    </jaxb:bindings>
    

    XJC Call

    The -b option is used with the XJC command to specify a binding file.

    xjc -b binding.xml myschema.xsd
    

    For More Information

    • http://blog.bdoughan.com/2011/07/jaxb-xjc-and-nested-classes.html
    0 讨论(0)
提交回复
热议问题