JAXB Bindings to schemas in a JAR

只谈情不闲聊 提交于 2019-12-03 16:14:17

What I'd like to have working here is something like:

<jaxb:bindings schemaLocation="maven:org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-tests-po!/purchaseorder.xsd" node="/xs:schema">
    <jaxb:schemaBindings>
        <jaxb:package name="org.jvnet.jaxb2.maven2.tests.po"/>
    </jaxb:schemaBindings>      
</jaxb:bindings>

But it does not at the moment. Please file an issue, I'll try to fix it.

What does work now is SCD-based binding:

<jaxb:bindings scd="x-schema::po" xmlns:po="urn:po">
    <jaxb:schemaBindings>
        <jaxb:package name="org.jvnet.jaxb2.maven2.tests.po"/>
    </jaxb:schemaBindings>      
</jaxb:bindings>

So you don't actually need to bind based on a specific schema location, you can bind based on the namespace URI, which is theoretically better.

Practically I have an experience that SCD-bindings don't always work reliably.

UPDATE

See this link for more information SCD usage in JAXB.

You need to use maven-dependency-plugin:unpack and then point maven-jaxb2-plugin to outputDirectory. In this case in binding file you need to say something like schemaLocation="../target/schemas/schema.xsd"

I know this is an old question but I was struggling with the same problem. I found that doing inline bindings would solve the problem. You would no longer have any need for the binding file and the bindings would be carried over to projects depending on it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!