I have the following project structure:
service-parent
|__service-schemas
|__service-database
|__service-contract
|__service-implementation
I am using hyperjaxb3 because I ultimately need that the objects passed through the web service are the ones that will be finally stored in the database (no transformations required).
In the module service-schemas I have defined the XSD schemas I will be using in my web service. service-database will generate JPA-JAXB objects through hyperjaxb3 use. service-contract will generate java service interfaces by using cxf-codegen-plugin maven plugin. service-implementation will be the final web service implementation. I think the idea is OK. However the problem rises when I use hyperjaxb3 and cxf-codegen-plugin, because I need JPA classes (the ones I generate using hyperjaxb3) to extend a BaseCustomClass. The problem is that when I create my test to, say, the web service method persitCustom(CustomType), the XML is being deserialized to CustomType as generated by cxf-codegen-plugin (which is the tool I used to generate service interfaces). Now, that class is not exactly the CustomType generated by hyperjaxb3 (even though it is not a problem at compile time, cause both classes are "almost" the same, same properties, same package, etc...) The question is how do I force my service implementation to use hyperjaxb3 generated classes instead of cxf-codegen-plugin generated ones.
These are the versions I am using
<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>
This is for 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>
答案 0 :(得分:0)
好的,我通过告诉cxf-codegen-plugin排除包含冲突类型的命名空间中的类来找到一种方法。我将这些行添加到插件的配置部分。它们位于 http://conflicting/types/namespace/ 命名空间
下<extraargs>
<extraarg>-nexclude</extraarg>
<extraarg>http://conflicting/types/namespace/</extraarg>
</extraargs>