自定义程序包名称cxf-codegen-plugin [英] Custom package names cxf-codegen-plugin

查看:58
本文介绍了自定义程序包名称cxf-codegen-plugin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想象一下这种情况.

我有一个名称空间为a/b/c的wsdl文件,它导入了另一个名称空间为m/n/o的wsdl.不幸的是,它们两个都在其中定义了相同的ComplexTypes XYZ.现在,当我使用cxf-codegen-plugin生成Java代码并使用自定义程序包名称"com.qsrs.uvw"时,在生成的最终代码中仅保留了一个类.有人可以帮我吗?

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?

推荐答案

如果要根据名称空间生成程序包,请使用以下解决方案:

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>

< extraarg> http://your.namespace2/services2/=your.package2</extraarg> 会将您的名称空间与您想要的包映射.

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

这篇关于自定义程序包名称cxf-codegen-plugin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆