久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何使用 JAXB 從 xsd 生成實現 Serializable 接口的

How to generate a Java class which implements Serializable interface from xsd using JAXB?(如何使用 JAXB 從 xsd 生成實現 Serializable 接口的 Java 類?)
本文介紹了如何使用 JAXB 從 xsd 生成實現 Serializable 接口的 Java 類?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想在一個現有的 Spring 項目中引入緩存,該項目使用 JAXB 來公開 WebServices.緩存將在端點級別完成.為了做到這一點,使用 JAXB 從 XSD 生成的類需要實現 Serializable 接口并覆蓋 ObjecttoString() 方法.

I would like to introduce caching into an existing Spring project which uses JAXB to expose WebServices. Caching will be done on the level of end points. In order to do that classes generated from XSD using JAXB need to implement Serializable interface and override Object's toString() method.

如何使用 XSD 指示 xjc 工具生成具有所需屬性的源代碼?

How to instruct the xjc tool using XSD to generate source with needed properties?

推薦答案

Serializable

在自定義綁定文件中使用 xjc:serializablejava.io.Serializable 接口與 serialVersionUID 一起添加到您的類中:

Serializable

Use xjc:serializable in a custom bindings file to add the java.io.Serializable interface to your classes along with a serialVersionUID:

<?xml version="1.0" encoding="UTF-8"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
            xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
            xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
            xsi:schemaLocation="
http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
version="2.1">
  <globalBindings>
    <serializable uid="1" />
  </globalBindings>
</bindings> 

toString()

使用一個超類(參見xjc:superClass),所有綁定的類都將從中繼承.這個類不會由 xjc 生成,所以你可以隨意創建它(這里使用 toString() 實現):

toString()

Use a superclass (see xjc:superClass) from which all your bound classes will inherit. This class won’t be generated by xjc so you are free to create it as you please (here with a toString() implementation):

<?xml version="1.0" encoding="UTF-8"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
                xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
                xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
                xsi:schemaLocation="
http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
    version="2.1">
    <globalBindings>
        <serializable uid="1" />
        <xjc:superClass name="the.package.to.my.XmlSuperClass" />
    </globalBindings>
</bindings>

這篇關于如何使用 JAXB 從 xsd 生成實現 Serializable 接口的 Java 類?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: av第一页| 天天爽天天操 | 亚洲区一| 中文字幕国产视频 | 亚洲电影一区 | 久久成人精品视频 | 国产福利在线 | 91精品国产色综合久久 | 日本不卡一二三 | 99久久国产综合精品麻豆 | 毛片在线视频 | 欧美日本在线观看 | 国产亚洲欧美日韩精品一区二区三区 | 视频一区二区中文字幕日韩 | 成年人在线观看 | 欧美日韩在线高清 | 99久久精品免费看国产四区 | 亚洲一区二区三区视频 | 九九九久久国产免费 | 日韩在线一区二区三区 | 国产精品久久视频 | 国产精品国产a级 | 一本久久a久久精品亚洲 | 国产一区视频在线 | 成av在线| 色偷偷888欧美精品久久久 | 韩国毛片一区二区三区 | 久久久久久91香蕉国产 | 日韩久久久久久 | 成人精品视频 | 四虎影院一区二区 | 自拍视频在线观看 | 欧美性高潮 | 日韩欧美一区在线 | 91久久精品日日躁夜夜躁国产 | 久久久久久网站 | 日韩精品一区二区三区在线观看 | 怡红院怡春院一级毛片 | 欧美成人一区二区 | 欧美精品一区二区免费 | 欧美日韩在线视频观看 |