【问题标题】:JAXB and collections containing genericsJAXB 和包含泛型的集合
【发布时间】:2010-11-09 16:51:43
【问题描述】:

我们有下面的 JAXB/Java 代码。在我们将 List<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
    ...

【问题讨论】:

    标签: java generics jaxb


    【解决方案1】:

    看看这篇 SO 帖子。我认为它有你需要的东西:JAXB Marshalling and Generics

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-24
      • 1970-01-01
      相关资源
      最近更新 更多