Unsupported binding namespace “”

会有一股神秘感。 提交于 2019-12-01 23:05:12

The error that you see is due to missing the prefix on tag <property name="xsid"/>. The correct tag is below

<jaxb:bindings node="//xs:complexType[@name='Section']/xs:attribute[@name='ID']">
    <jaxb:property name="xsid"/>
</jaxb:bindings>

Anyway your XSDs have some problem because by maven-jaxb2-plugin is possible to generates all classes and maven-hyperjaxb3-plugin is not possible.


I suggest a work around for your entire problem. If you don't needed to mark as @Entity or @Table all class that you generated, you could use below configuration.

XJB

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
    version="2.1"
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:annox="http://annox.dev.java.net"  >

    <jaxb:bindings schemaLocation="schema.xsd" node="/xs:schema">
        <jaxb:globalBindings generateIsSetMethod="true"/>
        <jaxb:schemaBindings>
            <jaxb:package name="org.jvnet.hyperjaxb3.ejb.tests.pocustomized"/>
        </jaxb:schemaBindings>
        <jaxb:bindings node="//xs:complexType[@name='InfrastructureRoot.typeId']">
            <annox:annotate>
                <annox:annotate annox:class="javax.persistence.Entity">
                </annox:annotate>
                <annox:annotate annox:class="javax.persistence.Table" name="typeId">
                </annox:annotate>
            </annox:annotate>
        </jaxb:bindings>
        <jaxb:bindings node="//xs:complexType[@name='ObservationMedia']/xs:attribute[@name='ID']">
            <jaxb:property name="xsid"/>
        </jaxb:bindings>
        <jaxb:bindings node="//xs:complexType[@name='RegionOfInterest']/xs:attribute[@name='ID']">
            <jaxb:property name="xsid"/>
        </jaxb:bindings>
        <jaxb:bindings node="//xs:complexType[@name='Section']/xs:attribute[@name='ID']">
            <jaxb:property name="xsid"/>
        </jaxb:bindings>


    </jaxb:bindings>

</jaxb:bindings>

Maven Plugin

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.8.1</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.1.Final</version>
        </dependency>
    </dependencies>
    <configuration>
        <args>
            <arg>-Xannotate</arg>
            <arg>-nv</arg>
        </args>
        <extension>true</extension>
        <schemaDirectory>src/main/resources/</schemaDirectory>
        <schemaIncludes>
            <schemaInclude>schema.xsd</schemaInclude>
        </schemaIncludes>
        <bindingDirectory>src/main/resources/</bindingDirectory>
        <bindingIncludes>
            <include>*.xjb</include>
        </bindingIncludes>
        <debug>true</debug>
        <verbose>true</verbose>
        <episode>true</episode>
        <forceRegenerate>true</forceRegenerate>
        <plugins>
            <plugin>
                <groupId>org.jvnet.jaxb2_commons</groupId>
                <artifactId>jaxb2-basics</artifactId>
                <version>0.6.3</version>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jaxb2_commons</groupId>
                <artifactId>jaxb2-basics-annotate</artifactId>
                <version>0.6.3</version>
            </plugin>
        </plugins>
    </configuration>
</plugin>

Ain't a best practices but works fine.

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