【问题标题】:maven-cxf-codegen-plugin using Jaxb binding to add inheritance for all generated classesmaven-cxf-codegen-plugin 使用 Jaxb 绑定为所有生成的类添加继承
【发布时间】:2014-07-20 14:47:35
【问题描述】:

我正在使用 Apache CXF 的 cxf-codegen-plugin 将 wsdl 转换为 java 对象。我指定了一个绑定文件来添加额外的 jaxb 处理。我希望所有这些文件都继承自一个接口(或扩展一个抽象类)。

我的问题是,虽然我可以使用它来处理一个生成的文件

<jaxb:bindings node="xsd:complexType[@name='sampleObj'] ">
        <inheritance:implements>example.Dao</inheritance:implements>
    </jaxb:bindings>

这将使 sampleObj 实现 example.Dao。 我不知道如何处理我所有的复杂类型(生成的类)。无需为 every 类 (>100)

重复上述绑定

我试过了,

 <jaxb:bindings  multiple="true" node="//xsd:compexType[@name='*'] ">

但它不起作用。

这是我的 maven 插件,如果有帮助的话:

 <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <executions>
                <execution>
                    <id>generate-resources</id>
                    <phase>process-resources</phase>
                    <configuration>
                        <sourceRoot>${project.build.directory}/generated/</sourceRoot>
                                               <wsdlOptions>
                            <wsdlOption>

                                <wsdl>${wsdl_location}</wsdl>
                                <wsdlLocation>classpath:wsdl.wsdl</wsdlLocation>

                                <!--<wsdlLocation>classpath:wsdl.wsdl</wsdlLocation>-->
                                <extraargs>
                                    <extraarg>-autoNameResolution</extraarg>
                                    <extraarg>-xjc-Xfluent-api</extraarg>
                                    <extraarg>-xjc-Xbg</extraarg>
                                    <extraarg>-verbose</extraarg>
                                    <extraargs>-validate</extraargs>
                                    <extraargs>-mark-generated</extraargs>
                                          <extraargs>-xjc-Xinheritance</extraargs>
                                    <extraarg>-p</extraarg>
                                    <extraarg>com.example</extraarg>
                                </extraargs>

                                <bindingFiles>
                                      <bindingFile>${project.build.directory}\classes\jax-ws_binding.xjb</bindingFile>

                                </bindingFiles>
                            </wsdlOption>
                        </wsdlOptions>

                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-fluent-api</artifactId>
                    <version>3.0</version>
                </dependency>
                <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics</artifactId>
                    <version>0.6.5</version>
                </dependency>
                <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics-annotate</artifactId>
                    <version>0.6.5</version>
                </dependency>
                 <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics-runtime</artifactId>
                    <version>0.6.5</version>
                </dependency>

                <dependency>
                    <groupId>org.apache.cxf.xjcplugins</groupId>
                    <artifactId>cxf-xjc-boolean</artifactId>
                    <version>2.7.0</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-api</artifactId>
                    <version>${cxf.version}</version>
                </dependency>
            </dependencies>
        </plugin>

    </plugins>

【问题讨论】:

  • 我想达到和你一样的效果..你找到答案了吗?

标签: java inheritance jaxb jax-ws cxf


【解决方案1】:

试试这个

<jaxb:bindings node="xsd:complexType">

【讨论】:

    【解决方案2】:

    啊,终于找到了:将multiple="true"添加到bindings标签中:

    <jaxb:bindings schemaLocation="../../../../contracts/src/main/resources/wsdl/ifx24.xsd">
        <jaxb:bindings node="xsd:complexType[contains(@name, 'Rq_Type')]" multiple="true">
            <inheritance:implements>hu.eir.ifx.IfxExchange</inheritance:implements>
        </jaxb:bindings>
    </jaxb:bindings>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-19
      • 2014-07-12
      相关资源
      最近更新 更多