簡體   English   中英

JAXB和包含泛型的集合

[英]JAXB and collections containing generics

我們在下面有JAXB / Java代碼。 這工作正常,直到我們將List<JQGridTO> rows更改為List<? extends JQGridTO> rows List<? extends JQGridTO> rows

當我們進行更改時,我們會收到此錯誤:

構造函數拋出異常; 嵌套異常是com.sun。 xml.bind.v2.runtime.IllegalAnnotationsException:1個IllegalAnnotationExceptions計數屬性行出現在@ XmlType.propOrder中,但不存在此類屬性。 也許你的意思是唱片? 此問題與以下位置有關:在com.me.ui.service.JQGridJsonRoot

為什么我們會收到此錯誤? 你不能像我們一樣使用泛型(即:指定? extends XXX )?

@XmlRootElement
@XmlType(name = "", propOrder = {
        "records",
        "page",
        "total",
        "rows"
})
public class JQGridJsonRoot {
    int total; //total pages for the query
    int page; //current page of the query
    int records; //total number of records for the query
    List<? extends JQGridTO> rows
    ...

看看這篇SO帖子。 我認為它有你需要的東西: JAXB編組和泛型

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM