我有以下项目结构:
服务父母
|__服务模式
|__服务数据库
|__服务合同
|__服务实施
我正在使用 hyperjaxb3,因为我最终需要通过 Web 服务传递的对象是最终存储在数据库中的对象(不需要转换)。
在模块服务模式中,我定义了我将在我的 Web 服务中使用的 XSD 模式。service-database将通过 hyperjaxb3 使用生成 JPA-JAXB 对象。service-contract将使用 cxf-codegen-plugin maven 插件生成 java 服务接口。service-implementation将是最终的 Web 服务实现。我认为这个想法是可以的。但是,当我使用 hyperjaxb3 和 cxf-codegen-plugin 时,问题就出现了,因为我需要 JPA 类(我使用 hyperjaxb3 生成的那些)来扩展BaseCustomClass。问题是,当我为 web 服务方法persitCustom(CustomType)创建测试时,XML 被反序列化为 CustomType由 cxf-codegen-plugin 生成(这是我用来生成服务接口的工具)。现在,该类不完全是由hyperjaxb3生成的 CustomType(即使它在编译时不是问题,因为两个类“几乎”相同,相同的属性,相同的包等......)问题是怎么做我强制我的服务实现使用 hyperjaxb3 生成的类而不是cxf-codegen-plugin生成的类。
这些是我正在使用的版本
<plugin>
<groupId>org.jvnet.hyperjaxb3</groupId>
<artifactId>maven-hyperjaxb3-plugin</artifactId>
<version>0.6.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<extension>true</extension>
<args>
<arg>-Xinheritance</arg>
</args>
</configuration>
</plugin>
这是针对 cxf-codegen-plugin
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.7.9</version>
<executions>
<execution>
<id>process-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>
${project.build.directory}/src/main/resources/SharedModel/sampleWeb/service.wsdl
</wsdl>
<wsdlLocation>classpath*:sampleWeb/service.wsdl</wsdlLocation>
<bindingFiles/>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>