【问题标题】:BadCommandLineException with maven cxf XJC pluginBadCommandLineException 与 maven cxf XJC 插件
【发布时间】:2014-06-16 13:08:30
【问题描述】:

我正在开发一个使用 CXF 生成 SOAP 客户端的 SOA 项目。
我需要使用cxf-xjc-boolean 插件来处理推土机映射和布尔属性,所以我遵循http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html 的文档,现在我有以下pom.xml 摘录:

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
    ...
<build>
    <plugins>
        <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>
                        <defaultOptions>
                            <frontEnd>jaxws21</frontEnd>
                        </defaultOptions>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${basedir}/src/main/wsdl/My.wsdl</wsdl>
                                <wsdlLocation>classpath:wsdl/My.wsdl</wsdlLocation>
                                <extraargs>
                                    <extraarg>-xjc-Xboolean</extraarg>
                                </extraargs>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<dependencies>
            ...
    <dependency>
        <groupId>org.apache.cxf.xjcplugins</groupId>
        <artifactId>cxf-xjc-boolean</artifactId>
        <version>2.7.0</version>
    </dependency>
</dependencies>
</project>

当我运行 generate-sources 目标时(通过 m2e Eclipse 插件或命令行),我收到此错误:

[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java (generate-sources) on project My-BL: Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:2.7.3:wsdl2java failed: XJC reported 'BadCommandLineException' for -xjc argument:-extension -Xts -target 2.1

如何修复我的 pom.xml 以使 plunig 正常工作?

顺便说一句,我注意到插件的 2.7.3 版本(与我正在使用的 CXF 版本一致的托管插件)在存储库中不可用,所以我使用的是 2.7.0。这可能是个问题吗?

【问题讨论】:

    标签: maven jaxb cxf


    【解决方案1】:

    需要两件事:

    1. 将 cxf-xjc-boolean 依赖项放在插件的 &lt;dependencies&gt; 中,而不是放在您的项目依赖项中。
    2. 正确的参数是bg(生成getXYZ() 方法)或bgi(生成getXYZ() 和isXYZ() 方法)而不是boolean

      <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>
                  <goals>
                      <goal>wsdl2java</goal>
                  </goals>
              </execution>
          </executions>
          <configuration>
              <sourceRoot>${basedir}/target/generated-sources</sourceRoot>
              <wsdlOptions>
                  <wsdlOption>
                      <wsdl>
                          ${basedir}/src/main/resources/PatientService.wsdl
                      </wsdl>
                      <wsdlLocation>classpath:PatientService.wsdl</wsdlLocation>
                      <extraargs>
                          <extraarg>-xjc-Xbgi</extraarg>
                      </extraargs>
                  </wsdlOption>
              </wsdlOptions>
          </configuration>
          <dependencies>
              <dependency>
                  <groupId>org.apache.cxf.xjcplugins</groupId>
                  <artifactId>cxf-xjc-boolean</artifactId>
                  <version>2.7.0</version>
              </dependency>
          </dependencies>
      </plugin>
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-20
      • 2018-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多