2016-11-25 91 views
0

我嘗試從一個maven依賴複製XSD文件,並把它放到目標文件夾與他人我的項目的XSD文件後,我萬特生成JAXB類,但它無法在同一時間生成它們。 當我只創建依賴關係的xsd文件的代碼時,它可以生成jaxb類,但是對於我的項目的xsd文件它不能。的Maven插件JAXB不能生成目標文件夾類

<plugin> 
    <!-- copy the xsdl files of my current project into the target folder--> 
      <artifactId>maven-resources-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>copy-resources-xsd</id> 
        <phase>generate-resources</phase> 
        <goals> 
         <goal>copy-resources</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>${basedir}/target/tmp/schemas</outputDirectory> 
         <encoding>UTF-8</encoding> 
         <resources> 
          <resource> 
           <directory>${basedir}/src/main/schemas</directory> 
           <includes> 
            <include>**/*.xsd</include> 
           </includes> 
          </resource> 
         </resources> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    <!--copy the xsd files of the dependency into the target folder of my current project--> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>copy-libraries</id> 
        <phase>generate-resources</phase> 
        <goals> 
         <goal>copy</goal> 
        </goals> 
        <configuration> 
         <artifactItems> 
          <artifactItem> 
           <groupId>com.my.dependency</groupId> 
           <artifactId>res-communes</artifactId> 
           <version>${res-communes.version}</version> 
           <type>xsd</type> 
           <classifier>typesFy</classifier> 
           <destFileName>typesFy.xsd</destFileName> 
           <outputDirectory>${project.build.directory}/tmp/schemas</outputDirectory> 
          </artifactItem> 
         </artifactItems> 
         <overWriteReleases>false</overWriteReleases> 
         <overWriteSnapshots>true</overWriteSnapshots> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.jvnet.jaxb2.maven2</groupId> 
      <artifactId>maven-jaxb2-plugin</artifactId> 
      <version>${maven-jaxb2-plugin.version}</version> 
      <dependencies> 
       <dependency> 
        <groupId>com.fasterxml.jackson.core</groupId> 
        <artifactId>jackson-annotations</artifactId> 
        <version>${jackson.version}</version> 
       </dependency> 
      </dependencies> 
      <executions> 
       <execution> 
        <goals> 
         <goal>generate</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <extension>true</extension> 
       <enableIntrospection>true</enableIntrospection> 
       <markGenerated>true</markGenerated> 
       <schemas> 
        <schema> 
         <fileset> 
          <directory>${project.build.directory}/tmp/schemas</directory> 
         </fileset> 
        </schema> 
       </schemas> 
       <args> 
        <arg>-Xts:style:org.apache.commons.lang.builder.ToStringStyle.MULTI_LINE_STYLE</arg> 
        <arg>-Xbg</arg> 
        <arg>-Xfluent-api</arg> 
        <arg>-Xinheritance</arg> 
        <arg>-Xannotate</arg> 
        <arg>-XJsr303Annotations</arg> 
       </args> 
       <plugins> 
        <plugin> 
         <groupId>org.jvnet.jaxb2_commons</groupId> 
         <artifactId>jaxb2-basics</artifactId> 
         <version>${jaxb2-basics.version}</version> 
        </plugin> 
        <plugin> 
         <groupId>org.jvnet.jaxb2_commons</groupId> 
         <artifactId>jaxb2-basics-annotate</artifactId> 
         <version>${jaxb2-basics-annotate.version}</version> 
        </plugin> 
        <plugin> 
         <groupId>org.apache.cxf.xjcplugins</groupId> 
         <artifactId>cxf-xjc-ts</artifactId> 
         <version>${cxf-xjc-ts.version}</version> 
        </plugin> 
        <plugin> 
         <groupId>org.apache.cxf.xjcplugins</groupId> 
         <artifactId>cxf-xjc-boolean</artifactId> 
         <version>${cxf-xjc-boolean.version}</version> 
        </plugin> 
        <plugin> 
         <groupId>org.jvnet.jaxb2_commons</groupId> 
         <artifactId>jaxb2-fluent-api</artifactId> 
         <version>${jaxb2-fluent-api.version}</version> 
        </plugin> 
        <plugin> 
         <groupId>com.github.krasa</groupId> 
         <artifactId>krasa-jaxb-tools</artifactId> 
         <version>${krasa-jaxb-tools.version}</version> 
        </plugin> 
       </plugins> 
      </configuration> 
     </plugin> 

回答

1

maven-jaxb2-plugin默認運行在generate-sources階段。你在generate-resources中解開你的模式。當你嘗試編譯它們時,模式還不存在。

要調試此類問題,請運行mvn -X clean install並檢查日誌。

相關問題