如何使wsdl生成的java类Serializable [英] How to make java class Serializable which is generated by wsdl

查看:85
本文介绍了如何使wsdl生成的java类Serializable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,类是由 wsdl 生成的.这些类之一是用户类.这个类必须是可序列化的.如何更改我的 pom.xml 文件以使用户可序列化?我可以找到示例但无法将其应用于我的项目https://pragmaticintegrator.wordpress.com/2009/03/14/make-serializable-jax-ws-clients-with-maven2/

In my project, classes are generated by wsdl. One of these classes is User class. This class must be Serializable. How can I change my pom.xml file for making User Serializable? I can find example but can't apply it to my project https://pragmaticintegrator.wordpress.com/2009/03/14/make-serializable-jax-ws-clients-with-maven2/

推荐答案

我终于找到了问题的答案.在我们的项目中,我们使用 org.apache.cxf 插件来生成类.我在资源文件夹中创建了 binding.xml 文件.

Finally I could find answer for my question. In our project we use org.apache.cxf plugin to generate classes. I created binding.xml file in resources folder.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
           xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
           elementFormDefault="qualified" attributeFormDefault="unqualified"
           jaxb:extensionBindingPrefixes="xjc" jaxb:version="2.1">
    <xs:annotation>
        <xs:appinfo>
            <jaxb:globalBindings>
                <xjc:serializable uid="1337" />
            </jaxb:globalBindings>
        </xs:appinfo>
    </xs:annotation>
</xs:schema>

然后我从我的 pom.xml 中引用了这个 xml 文件,为此我添加了

Then I referenced to this xml file from my pom.xml, for this I added

<bindingFiles>
    <bindingFile>${basedir}/src/main/resources/binding.xml</bindingFile>
</bindingFiles>

在 wsdlOptions/wsdlOption 标签下.就这些

under wsdlOptions/wsdlOption tag. That's all

这篇关于如何使wsdl生成的java类Serializable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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