2014-02-18 24 views
6

我已經研究過這個問題的其他答案,但我還沒有能夠解決我的具體問題。我試圖使用Maven和cxf-codegen插件生成源客戶端java文件。當我運行mvn generate-sources時,它會告訴我BUILD BUILD SESSCESS但沒有任何生成。任何幫助表示讚賞。這裏是我的POM:Maven cxf-codegen-plugin不會生成源文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.tfs.common</groupId> 
    <artifactId>SpringCXF1</artifactId> 
    <packaging>war</packaging> 
    <version>0.0.1-SNAPSHOT</version> 

    <name>SpringCXF1 Maven Webapp</name> 
    <url>http://maven.apache.org</url> 

    <properties> 
     <cxf.version>2.7.3</cxf.version> 
     <project.build.sourceencoding>UTF-8</project.build.sourceencoding> 
    </properties> 

    <dependencies> 

    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-rt-frontend-jaxws</artifactId> 
     <version>${cxf.version}</version> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-rt-transports-http</artifactId> 
     <version>${cxf.version}</version> 
    </dependency> 

    </dependencies> 

    <build> 
    <finalName>SpringCXF1</finalName> 
     <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> 
     </configuration> 
    </plugin> 

     <!-- Generate Java classes from WSDL during in generate-sources phase --> 
     <plugin> 
     <groupId>org.apache.cxf</groupId> 
     <artifactId>cxf-codegen-plugin</artifactId> 
     <version>${cxf.version}</version> 
     <executions> 
     <execution> 
      <id>generate-sources</id> 
      <phase>generate-sources</phase> 
      <configuration> 
      <sourceroot>${basedir}/src/main/java</sourceroot> 
      <wsdloptions> 
      <wsdloption> 
      <wsdl>${basedir}/src/main/resources/HostavailableService.wsdl</wsdl> 
      <extraargs> 
       <extraarg>-verbose</extraarg> 
        <extraarg>-client</extraarg> 
      </extraargs> 
      </wsdloption> 
      </wsdloptions> 
      </configuration> 
      <goals> 
      <goal>wsdl2java</goal> 
      </goals> 
     </execution> 
     </executions> 
     </plugin> 

     <!-- Add generated source --> 
     <plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>build-helper-maven-plugin</artifactId> 
     <version>1.7</version> 
     <executions> 
     <execution> 
      <id>add-source</id> 
      <phase>generate-sources</phase> 
      <goals> 
      <goal>add-source</goal> 
      </goals> 
      <configuration> 
      <sources> 
      <source>${basedir}/src/main/java</source> 
      </sources> 
      </configuration> 
     </execution> 
     </executions> 
     </plugin> 

     <plugin> 
     <groupId>org.eclipse.m2e</groupId> 
     <artifactId>lifecycle-mapping</artifactId> 
     <version>1.0.0</version> 
     <configuration> 
      <lifecyclemappingmetadata> 
      <pluginexecutions> 
      <pluginexecution> 
      <pluginexecutionfilter> 
       <groupid>org.apache.cxf</groupid> 
       <artifactid>cxf-codegen-plugin</artifactid> 
       <versionrange>[2.3.3,)</versionrange> 
       <goals> 
       <goal>wsdl2java</goal> 
       </goals> 
      </pluginexecutionfilter> 
      <action> 
       <execute> 
      </execute></action> 
      </pluginexecution> 
      </pluginexecutions> 
      </lifecyclemappingmetadata> 
      <lifecycleMappingMetadata> 
      <pluginExecutions> 
       <pluginExecution> 
        <pluginExecutionFilter> 
         <groupId>org.apache.cxf</groupId> 
         <artifactId>cxf-codegen-plugin</artifactId> 
         <versionRange>[2.7.3,)</versionRange> 
         <goals> 
          <goal>wsdl2java</goal> 
         </goals> 
        </pluginExecutionFilter> 
        <action> 
         <ignore></ignore> 
        </action> 
       </pluginExecution> 
       <pluginExecution> 
        <pluginExecutionFilter> 
         <groupId>org.codehaus.mojo</groupId> 
         <artifactId> 
          build-helper-maven-plugin 
         </artifactId> 
         <versionRange>[1.7,)</versionRange> 
         <goals> 
          <goal>add-source</goal> 
         </goals> 
        </pluginExecutionFilter> 
        <action> 
         <ignore></ignore> 
        </action> 
       </pluginExecution> 
      </pluginExecutions> 
      </lifecycleMappingMetadata> 
     </configuration> 
     </plugin> 
     </plugins> 

    </build> 

</project> 

這裏是MVN運行產生來源,當輸出:

[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building SpringCXF1 Maven Webapp 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- cxf-codegen-plugin:2.7.3:wsdl2java (generate-sources) @ SpringCXF1 --- 
[INFO] Nothing to generate 
[INFO] 
[INFO] --- build-helper-maven-plugin:1.7:add-source (add-source) @ SpringCXF1 --- 
[INFO] Source directory: /Users/dmattrm/Documents/DevEnvironment/TFS_Maven2/SpringCXF1/src/main/java added. 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1.505s 
[INFO] Finished at: Tue Feb 18 16:54:04 CST 2014 
[INFO] Final Memory: 5M/81M 
[INFO] ------------------------------------------------------------------------ 

回答

3

Maven的XML標記爲CXF插件是大小寫敏感的,這應該工作:

<configuration> 
    <sourceRoot>${basedir}/src/main/java</sourceRoot> 
    <wsdlOptions> 
     <wsdlOption> 
      <wsdl>${basedir}/src/main/resources/HostavailableService.wsdl</wsdl> 
      <extraargs> 
       <extraarg>-verbose</extraarg> 
       <extraarg>-client</extraarg> 
      </extraargs> 
     </wsdlOption> 
    </wsdlOptions> 
</configuration> 
+0

謝謝。那工作。 –

0

也看看你的./target/-文件夾。一旦代碼生成運行成功,您可以在這裏找到文件夾cxf-codegen-plugin-markers。 您必須刪除此文件夾,以強制CXF再次運行代碼生成。