Custom package names cxf-codegen-plugin

我的未来我决定 提交于 2021-02-05 20:07:25

问题


Imagine this scenario.

I have a wsdl file with namespace a/b/c and it imports another wsdl whose namespace is m/n/o. Unfortunately, both of them have same ComplexTypes XYZ defined in them. Now, when I use cxf-codegen-plugin to generate Java code and use custom package name "com.qsrs.uvw", only one class is retained in the final code that is generated. Can someone help me out here?


回答1:


If you want to generate package depending on the namespace here is the solution:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>2.6.0</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>yourWsdl.wsld</wsdl>
                        <extraargs>
                            <extraarg>-client</extraarg>
                            <extraarg>-verbose</extraarg>
                            <extraarg>-p</extraarg>
                            <extraarg>http://your.namespace/services/=your.package</extraarg>
                            <extraarg>-p</extraarg>
                            <extraarg>http://your.namespace2/services2/=your.package2</extraarg>
                        </extraargs>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

This <extraarg>http://your.namespace2/services2/=your.package2</extraarg> will map your namespace with the package you want.



来源:https://stackoverflow.com/questions/12605379/custom-package-names-cxf-codegen-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!