久久久久久久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(使用線程逐塊處理文件)
主站蜘蛛池模板: 伊人网站在线 | 98久久| 欧美在线免费 | 天堂久久一区 | 成人免费一区二区三区视频网站 | 午夜影院在线观看 | re久久| 亚洲一区二区三区视频 | 精品无码久久久久国产 | 日本视频免费观看 | 九九色综合 | 一区二区三区欧美在线 | 黄色网址在线免费播放 | 国产高清免费视频 | 九九在线视频 | 欧美成人h版在线观看 | 91国自产| 在线天堂免费中文字幕视频 | 91精品国产色综合久久 | 国产亚洲网站 | 蜜桃一区二区三区在线 | 国产精品精品视频一区二区三区 | 7777在线视频免费播放 | 免费久久久 | 91就要激情| 久久精品视频免费观看 | 99re在线视频 | 草草草影院 | 日韩av免费看 | 欧美日韩成人影院 | 午夜影院在线观看 | 伊人久久精品 | 亚洲国产精品一区二区第一页 | 免费在线观看av网址 | 久久网国产| 亚洲国产网| 女女爱爱视频 | 日韩精品一区二区三区中文在线 | 一区二区三区小视频 | 日本精品久久 | 亚洲精品9999 |