gpt4 book ai didi

java - maven-cxf-codegen-plugin 使用 Jaxb 绑定(bind)为所有生成的类添加继承

转载 作者:搜寻专家 更新时间:2023-11-01 03:51:57 25 4
gpt4 key购买 nike

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

我的问题是,虽然我可以使用

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

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

重复上述绑定(bind)

我试过了,

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

最佳答案

试试这个

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

关于java - maven-cxf-codegen-plugin 使用 Jaxb 绑定(bind)为所有生成的类添加继承,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23961421/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com