Java Maven cxf-codegen-plugin 不生成源码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21867477/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 11:09:30  来源:igfitidea点击:

Maven cxf-codegen-plugin does not generate source

javamavencxf

提问by David Matthews

I've researched other answers to this question but I haven't been able to fix my specific issue yet. I'm trying to generate source client java files using Maven and the cxf-codegen-plugin. When I run mvn generate-sources it tells me BUILD SUCCESS but Nothing to generate. Any help is appreciated. Here is my pom:

我已经研究了这个问题的其他答案,但我还没有能够解决我的具体问题。我正在尝试使用 Maven 和 cxf-codegen-plugin 生成源客户端 java 文件。当我运行 mvn generate-sources 时,它告诉我 BUILD SUCCESS 但没有生成。任何帮助表示赞赏。这是我的pom:

<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>

Here is the output when running mvn generate-sources:

这是运行 mvn generate-sources 时的输出:

[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] ------------------------------------------------------------------------

采纳答案by bgossit

The Maven XML tags for the CXF plugin are case sensitive, this should work:

CXF 插件的 Maven XML 标签区分大小写,这应该有效:

<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>

回答by gratinierer

Also have a look to your ./target/-Folder. Once the code-generation has run successfully, you can find here the Folder cxf-codegen-plugin-markers. You have to delete this folder, to force CXFto run the code-generation again.

也看看你的./target/-Folder。代码生成成功运行后,您可以在此处找到 Folder cxf-codegen-plugin-markers。您必须删除此文件夹,以强制CXF再次运行代码生成。