[英]How to use JAXB autoInheritance for generated classes from WSDL?
我正在从soap
webservices wsdl
生成Java类。
这些请求不共享一个公共接口,但是我希望它们实现一个接口或扩展一个公共类。
因此,我正在尝试使用xcj-plugin
。 该声明
<extraarg>-xjc-XautoInheritance-xmlRootElementsImplement=com.path.to.BaseInterface</extraarg>
应该注意这一点,并让所有@XmlRootElement
注释类自动实现定义的BaseInterface
。
但是生成的类没有这个。 没有任何类正在实现此接口。 为什么? 以下配置可能出什么问题?
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<wsdlOptions>
<extraargs>
<extraarg>-xjc-XautoInheritance-xmlRootElementsExtend=com.path.to.BaseClass</extraarg>
<extraarg>-xjc-XautoInheritance-xmlRootElementsImplement=com.path.to.BaseInterface</extraarg>
<extraarg>-fe</extraarg>
<extraarg>cxf</extraarg>
<extraarg>-mark-generated</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2.10-b140310.1920</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.8.2</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
<version>0.8.2</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-jaxb-xjc</artifactId>
<version>2.2.4-1</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.1.10.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
请添加-xjc-XautoInheritance
以激活插件。
有关JAXB2 Basics插件的CXF使用,请参见以下页面 :
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<configuration>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/CustomerService.wsdl</wsdl>
<bindingFiles>
<bindingFile>${basedir}/src/main/wsdl/binding.xml</bindingFile>
<bindingFile>${basedir}/src/main/wsdl/binding.xjb</bindingFile>
</bindingFiles>
<extraargs>
<extraarg>-xjc-XhashCode</extraarg>
<extraarg>-xjc-Xequals</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version><!-- version --></version>
</dependency>
</dependencies>
</plugin>
免责声明:我是JAXB2 Basics插件的作者。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.