jaxb绑定找不到架构

时间:2015-10-19 02:41:12

标签: java jaxb jaxb2

您好我有以下绑定:

<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
               xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
               xmlns:annox="http://annox.dev.java.net"
               jaxb:extensionBindingPrefixes="xjc simplify annox" jaxb:version="2.1">
    <jaxb:bindings>
        <jaxb:globalBindings typesafeEnumMaxMembers="3235"/>
    </jaxb:bindings>
     <jaxb:bindings schemaLocation="jaxb/niem2/socd-x.xsd"></jaxb:bindings>
      <jaxb:bindings node="xsd:complexType[@name='SurveyControlAndDataMessageType']">
        <annox:annotate>
          <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="SurveyControlAndDataMessageType"/>
        </annox:annotate>
      </jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

我的绑定文件位于src/main/resources,xsd位于src/main/resources/jaxb/niem2。但是,无论何时我建立我都会得到:

  

com.sun.istack.SAXParseException2;的systenId:   文件:/ C:/work/MOJO/MOJOInterfaces/src/main/resources/bindings.xjb;   lineNumber:16; columnNumber:60;

“file:/ C:/work/MOJO/MOJOInterfaces/src/main/resources/jaxb/niem2/socd-x.xsd”不是此编译的一部分。这是“file:/ C:/work/MOJO/MOJOInterfaces/src/main/resources/MaestroGeoData.xsd?

的错误

这是pom的相关部分

<plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.12.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <id>jaxb-generate-workload</id>
                        <configuration>
                            <schemaDirectory>src/main/resources</schemaDirectory>
                            <schemaIncludes>
                                <include>MaestroSdfAndWorkloadTypes.xsd</include>
                            </schemaIncludes>
                            <generatePackage>mojo.interfaces.mocs.input</generatePackage>
                            <generateDirectory>${project.build.directory}/generated-sources/xjc-mocs</generateDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <id>jaxb-generate-niem2</id>
                        <configuration>
                            <args>
                                <arg>-XautoNameResolution</arg>
                                <arg>-npa</arg>
                                <arg>-verbose</arg>
                            </args>
                            <schemaIncludes>
                                <include>jaxb/niem2/*.xsd</include>
                            </schemaIncludes>
                            <episodeFile>${project.build.directory}/generated-sources/xjc-niem/META-INF/jaxb-niem2.episode</episodeFile>
                            <generateDirectory>${project.build.directory}/generated-sources/xjc-niem</generateDirectory>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <extension>true</extension>
                    <args>
                        <arg>-XtoString</arg>
                        <arg>-Xequals</arg>
                        <arg>-XhashCode</arg>
                        <arg>-Xcopyable</arg>
                        <arg>-Xmergeable</arg>
                        <arg>-Xsimplify</arg>
                    </args>
                    <verbose>true</verbose>
                    <plugins>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-basics</artifactId>
                            <version>0.9.1</version>
                        </plugin>
                        <plugin>
                            <groupId>org.jvnet.jaxb2_commons</groupId>
                            <artifactId>jaxb2-basics-annotate</artifactId>
                            <version>0.6.2</version>
                        </plugin>
                    </plugins>
                </configuration> 
                <dependencies>
                    <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-simple</artifactId>
                        <version>1.7.5</version>
                    </dependency>                    
                </dependencies>
            </plugin>

我验证了驱动器上存在的xsd,还有其他想法吗?

谢谢,

修改 所以我发现它有问题,因为它为jaxb插件中的每个执行使用相同的绑定文件。现在我需要弄清楚如何让它只获取应该使用它的执行的绑定文件。

1 个答案:

答案 0 :(得分:0)

我通过将binding.jxb放在它自己的目录中并在Execution中指定应该使用该绑定的目录来修复它,例如:

<execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <id>jaxb-generate-niem2</id>
                    <configuration>
                        <args>
                            <arg>-XautoNameResolution</arg>
                             <arg>-Xannotate</arg>
                            <arg>-npa</arg>
                            <arg>-verbose</arg>
                        </args>
                        <schemaDirectory>src/main/resources/jaxb/niem</schemaDirectory>
                        <bindingDirectory>src/main/resources/jaxb/niem/binding</bindingDirectory>
                        <episodeFile>${project.build.directory}/generated-sources/xjc-niem/META-INF/jaxb-niem2.episode</episodeFile>
                        <generateDirectory>${project.build.directory}/generated-sources/xjc-niem</generateDirectory>
                    </configuration>
                </execution>