2015-10-19 58 views
0

您好,我有以下綁定:JAXB綁定找不到架構

<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; systemId: file:/ C:/work/MOJO/MOJOInterfaces/src/main/resources/bindings.xjb; lineNumber:16; columnNumber:60;

「文件:/ C:/work/MOJO/MOJOInterfaces/src/main/resources/jaxb/niem2/socd-x.xsd」 不是此編譯的一部分。這是「文件的錯誤:/ 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存在於驅動器上,任何其他的想法

感謝,

編輯: 所以我想通了,這是因爲它是使用相同的綁定文件的每個我甲肝處決的有問題e在jaxb插件中。現在我需要弄清楚如何讓它只接收它應該使用它的執行的綁定文件。

回答

0

我通過將binding.jxb在自己的目錄,並指定在執行該目錄應利用這一結合,例如:

<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> 
固定它