2013-02-15 57 views
1

我想用maven cxf-codegen-plugin從WSDL創建一個Java類,但是當我嘗試這樣做時,它只是顯示錯誤而沒有生成類。從WSDL創建Java類

我不明白爲什麼我有這個錯誤,我的pom文件對我來說看起來沒問題。

pom.xml看起來像

<dependencies> 
    <dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-web-api</artifactId> 
     <version>6.0</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>3.2.1.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-rt-frontend-jaxws</artifactId> 
     <version>2.7.3</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-rt-transports-http-hc</artifactId> 
     <version>2.7.3</version> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.17</version> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-bundle</artifactId> 
     <version>2.5.1</version> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
       <compilerArguments> 
        <endorseddirs>${endorsed.dir}</endorseddirs> 
       </compilerArguments> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.1.1</version> 
      <configuration> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.1</version> 
      <executions> 
       <execution> 
        <phase>validate</phase> 
        <goals> 
         <goal>copy</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>${endorsed.dir}</outputDirectory> 
         <silent>true</silent> 
         <artifactItems> 
          <artifactItem> 
           <groupId>javax</groupId> 
           <artifactId>javaee-endorsed-api</artifactId> 
           <version>6.0</version> 
           <type>jar</type> 
          </artifactItem> 
         </artifactItems> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.cxf</groupId> 
      <artifactId>cxf-codegen-plugin</artifactId> 
      <version>2.7.3</version> 

      <executions> 
       <execution> 
        <id>generate-sources</id> 
        <phase>generate-sources</phase> 
        <configuration> 
         <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot> 
         <wsdlOptions> 
          <wsdlOption> 
           <wsdl>${basedir}/src/main/resources/CurrentTimeService.wsdl</wsdl> 
          </wsdlOption> 
         </wsdlOptions> 
        </configuration> 
        <goals> 
         <goal>wsdl2java</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.jvnet.jaxb2.maven2</groupId> 
      <artifactId>maven-jaxb2-plugin</artifactId> 
      <executions> 
       <execution> 
        <goals> 
         <goal>generate</goal> 
        </goals> 
        <configuration> 
         <schemaIncludes> 
          <include>jaxb/try/*.xsd</include> 
         </schemaIncludes> 
         <episodeFile>${project.build.directory}/generated-sources/xjc/META-INF/jaxb-try.episode</episodeFile> 
        </configuration> 
        <id>jaxb-generate-try</id> 
       </execution> 
       <execution> 
        <goals> 
         <goal>generate</goal> 
        </goals> 
        <configuration> 
         <schemaIncludes> 
          <include>jaxb/try/*.xsd</include> 
         </schemaIncludes> 
         <episodeFile>${project.build.directory}/generated-sources/xjc/META-INF/jaxb-try.episode</episodeFile> 
         <generatePackage>q1.q2</generatePackage> 
        </configuration> 
        <id>jaxb-generate-try_1</id> 
       </execution> 
       <execution> 
        <goals> 
         <goal>generate</goal> 
        </goals> 
        <configuration> 
         <schemaIncludes> 
          <include>jaxb/try2/*.xsd</include> 
         </schemaIncludes> 
         <episodeFile>${project.build.directory}/generated-sources/xjc/META-INF/jaxb-try2.episode</episodeFile> 
        </configuration> 
        <id>jaxb-generate-try2</id> 
       </execution> 
      </executions> 
      <configuration> 
       <catalog>src/main/resources/jaxb/catalog.xml</catalog> 
       <catalogResolver>org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver</catalogResolver> 
       <forceRegenerate>true</forceRegenerate> 
       <generateDirectory>${project.build.directory}/generated-sources/xjc</generateDirectory> 
       <verbose>true</verbose> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

當我用Maven構建這個項目,我看到下面的錯誤

Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java (generate-sources) on project WebServicesTest: org.xml.sax.SAXParseException; systemId: jar:file:/C:/Users/user/.m2/repository/com/sun/xml/bind/jaxb-xjc/2.2.6/jaxb-xjc-2.2.6.jar!/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd; lineNumber: 86; columnNumber: 48; src-resolve: Cannot resolve the name 'xjc:globalJavaType' to a(n) 'group' component. 
+0

'xjc:globalJavaType'似乎是JAXB問題,如果有幫助.... – Puce 2013-02-15 14:27:37

+0

POM不好看_to me _...你有兩個不同的CXF版本,2.7.3和2.5.1。另外,提供WSDL和XSD文件。 – 2013-02-15 14:30:14

+0

與兩個2.7.3版本相同的問題 – Olexii 2013-02-15 14:48:42

回答

4

看一看這個帖子:

Cannot resolve the name 'xjc:globalJavaType' in jaxb-xjc-2.2.5-2.jar

你可能在p中有非拉丁字符運行到您當地的Maven回購。嘗試改變你的settings.xml來設置一些只包含拉丁字符的其他目錄,看看是否有幫助。

+0

謝謝,我會盡量改變我的回購地點 – Olexii 2013-02-15 14:49:12

+0

偉大的,改變爲maven本地存儲庫中的拉丁字符有幫助! 謝謝! – Olexii 2013-02-15 15:03:23

+0

沒問題,很高興我可以幫忙! :) – 2013-02-15 15:58:02