修改从wsdl生成的java类的包名称 [英] Modify package names for java classes generated from wsdl
本文介绍了修改从wsdl生成的java类的包名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何修改从多个wsdls生成的java类的包名称。我有两个wsdls,它们都生成类ObjectFactory,package-info等类,具有完全相同的包名。因此,我无法在我的代码中组织导入。我的包对于wsdls看起来像这样 -
How do I modify package names for java classes generated from multiple wsdls. I have two wsdls, and both are generating classes like ObjectFactory, package-info etc with the exact same package name. As a result, I am not able to organize the imports in my code. My packages look like this for the wsdls -
WSDL A
com.test.customerinfo.dto
com.test.customerinfo.exceptions
com.test.customerinfo.service
WSDL B
com.test.customerinfo.dto
com.test.customerinfo.exceptions
com.test.customerinfo.service
我希望它看起来像这样 -
I want it to look something like this -
WSDL A
com.test.customerinfo.dto
com.test.customerinfo.exceptions
com.test.customerinfo.service
WSDL B
com.testOne.customerinfo.dto
com.testOne.customerinfo.exceptions
com.testOne.customerinfo.service
我试过这个,但是没有用 -
I tried this, but it didn't work -
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.7.7</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>target/generated-sources/test/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>src/main/resources/wsdl/test/GetInfo.wsdl</wsdl>
<extraargs>
<extraarg>-server</extraarg>
<extraarg>-client</extraarg>
<extraarg>-impl</extraarg>
<extraarg>-verbose</extraarg>
<extraarg>-p</extraarg>
<extraarg>http://dto.customerinfo.test.com/=com.test.customerinfo.dto</extraarg>
<extraarg>-p</extraarg>
<extraarg>http://services.customerinfo.test.com/=com.test.customerinfo.services</extraarg>
<extraarg>-p</extraarg>
<extraarg>http://exceptions.customerinfo.test.com/=com.test.customerinfo.exceptions</extraarg>
</extraargs>
<frontEnd>jaxws21</frontEnd>
<faultSerialVersionUID>1</faultSerialVersionUID>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
请指教。
推荐答案
在 cxf-codgen-plugin
中,您可以在 wsdlOptions
部分指定包映射:
In cxf-codgen-plugin
you can specify package mapping in the wsdlOptions
section:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
...
<configuration>
...
<wsdlOptions>
<wsdlOption>
...
<packagenames>
<!-- Package Mappings -->
<packagename>http://namespace.example.com/=com.test.package</packagename>
</packagenames>
...
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
或者您也可以使用 extraarg
:
<wsdlOptions>
<wsdlOption>
...
<extraargs>
<extraarg>-p</extraarg>
<extraarg>http://namespace.example.com/=com.test.package</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
这篇关于修改从wsdl生成的java类的包名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文