久久久久久久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| 影音先锋中文字幕在线观看 | 日韩欧美在线观看 | 午夜久久av | 337p日本欧洲亚洲大胆精蜜臀 | 国产免费一区二区三区免费视频 | 在线成人福利 | 波多野结衣一区二区 | 亚洲日本视频 | 久久久久精 | 国产在线视频一区二区 | 亚洲 中文 欧美 日韩 在线观看 | 午夜三区| 午夜精品一区二区三区三上悠亚 | 欧美亚洲另类在线 | www.夜夜骑 | 亚洲国产黄 | 久久9精品 | 国产一区二区三区在线 | 日本小视频网站 | 精品国产精品三级精品av网址 | 特黄毛片 | 97色在线观看免费视频 | 99精品久久| 亚洲网在线| www.日韩系列 | 91av在线视频观看 | 综合久久久久 | 国产午夜精品福利 | 噜久寡妇噜噜久久寡妇 | 天堂一区 | 欧美一区二区三区精品 | 久久久久国产精品人 | 成人精品国产 | 免费av在线网站 | 在线一区二区三区 | 天天干天天玩天天操 |