注释CXF(wsdl2java)生成的包 [英] Annotating CXF (wsdl2java) generated package

查看:450
本文介绍了注释CXF(wsdl2java)生成的包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要添加包级别注释(XmlJavaTypeAdapters类型适配器)。问题是,当我运行wsdl2java时,它会为该包生成package-info.java文件。

I need to add package level annotation (XmlJavaTypeAdapters type adapter). The problem is that when I run wsdl2java it generates package-info.java file for that package.

当我尝试添加自己的package-info.java时出现错误:类型package-ingo已经定义了。

When I try to add my own package-info.java I get error: "the type package-ingo is already defined".

有没有办法将我的注释注入package-info.java?也许还有其他想法吗?

Is there a way to inject my annotation to package-info.java?? Maybe any other ideas?

谢谢

推荐答案

经过一番研究后我使用外部映射文件。对于所有与我有类似问题的人,我在下面描述了我发现的内容。

After some research I used external mapping file. For all that have similar problem to mine I have described below what I have found.

如果你使用cxf-codegen-plugin从WSDL生成源代码你不能与package-info.java一起使用解决方案。这是因为生成的代码可能已经包含此文件。您也不能为类添加注释,因为它是生成的。唯一的解决方案是提供自己的映射器。

If you are using "cxf-codegen-plugin" for generating source code from WSDL you can't use solution with package-info.java. This is because generated code propably will already contain this file. You cannot also add annotation to your class because it is generated. The only solution is to provide your own mapper.

首先,你必须编写自定义映射器。之后,您应该定义xjb映射文件,最后将其他配置添加到您的pom.xml中。您可以在此处了解前两个步骤。

First of all you have to write custom mapper. After that you should define xjb mapping file and finally add additional configuration to your pom.xml. You can read about first two steps here.

要将外部映射文件添加到cxf-codegen-plugin,您必须在插件定义中向配置节点添加类似这样的内容:

To add external mapping file to cxf-codegen-plugin you have to add something like this to configuration node in plugin definition:

<defaultOptions>
    <bindingFiles>
        <bindingFile>${basedir}/src/main/resources/mapping.xjb</bindingFile>
    </bindingFiles>
    <noAddressBinding>true</noAddressBinding>
</defaultOptions>

请注意,您不应将额外参数传递给xjc,如上所述这里,因为它不起作用。

Note that you should not pass extra parameters to xjc as described here because it will not work.

希望这个会帮助任何人:)

Hope this will help anybody :)

这篇关于注释CXF(wsdl2java)生成的包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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