2

JAXB アノテーションを持つ 2 つの Scala ケース クラスがあります。

@XmlRootElement
@XmlSeeAlso({ Array(classOf[Element]) })
case class Config(
    @(XmlElement @field) name: String,
    @(XmlElement @field) reelCount: Int,
    @(XmlElement @field) slots: Int,
    @(XmlElementWrapper @field)@(XmlAnyElement @field) elements: List[Element]) {
    private def this() = this("", 0, 0, new ArrayList())
}

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
case class Element(
    @(XmlAttribute @field)@(XmlID @field) id: Int,
    @(XmlElement @field) name: String,
    @(XmlElement @field) imgPath: String) {
    private def this() = this(0, "", "")
}

@(XmlID @field)要素の最初の属性から注釈を削除すると、マーシャリングが機能します。xml id フィールドで注釈を付けると、次の例外が発生します。

[IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions]

この 2 つの注釈を使用して Java で動作するはずですが、Scala で何が間違っているのかわかりません。何か案は?または多分いくつかの回避策?

4

1 に答える 1