2017-12-19 7 views
0

私はクラスがあります。のJava:JAXB IllegalAnnotationException JAXBContext.newInstanceを呼び出す()

import javax.xml.bind.annotation.*; 

@XmlRootElement 
class Plansza 
{ 
    String tura; 

    String b0; 
    String b1; 
    String b2; 

    String b3; 
    String b4; 
    String b5; 

    String b6; 
    String b7; 
    String b8; 


    @XmlElement 
    public String getTura() 
    { 
     return this.tura; 
    } 

    public void setTura(String tura) 
    { 
     this.tura = tura; 
    } 

    @XmlElement 
    public String getB0() 
    { 
     return this.b0; 
    } 

    public void setB0(String b0) 
    { 
     this.b0 = b0; 
    } 

    @XmlElement 
    public String getB1() 
    { 
     return this.b1; 
    } 

    public void setB1(String b1) 
    { 
     this.b1 = b1; 
    } 

    @XmlElement 
    public String getB2() 
    { 
     return this.b2; 
    } 

    public void setB2(String b2) 
    { 
     this.b2 = b2; 
    } 

    @XmlElement 
    public String geB3() 
    { 
     return this.b3; 
    } 

    public void setB3(String b3) 
    { 
     this.b3 = b3; 
    } 

    @XmlElement 
    public String getB4() 
    { 
     return this.b4; 
    } 

    public void setB4(String b4) 
    { 
     this.b4 = b4; 
    } 

    @XmlElement 
    public String getB5() 
    { 
     return this.b5; 
    } 

    public void setB5(String b5) 
    { 
     this.b5 = b5; 
    } 

    @XmlElement 
    public String getB6() 
    { 
     return this.b6; 
    } 

    public void setB6(String b6) 
    { 
     this.b6 = b6; 
    } 

    @XmlElement 
    public String getB7() 
    { 
     return this.b7; 
    } 

    public void setB7(String b7) 
    { 
     this.b7 = b7; 
    } 

    @XmlElement 
    public String getB8() 
    { 
     return this.b8; 
    } 

    public void setB8(String b8) 
    { 
     this.b8 = b8; 
    } 
} 

私はXMLにシリアライズし、XMLファイルから、このようなクラスを読みたいです。私は、コンテキストを作成していたときに しかし:

JAXBContext context = JAXBContext.newInstance(Plansza.class); 

それはIllegalAnnotationsExceptionをスロー:

com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions 
JAXB annotation is placed on a method that is not a JAXB property 
    this problem is related to the following location: 
     at @javax.xml.bind.annotation.XmlElement(name=##default, namespace=##default, type=class javax.xml.bind.annotation.XmlElement$DEFAULT, required=false, defaultValue=, nillable=false) 
     at Plansza 

私はコンストラクタを追加しようとしたが、何も動いていないようにみえ、STIL同じ例外を取得します。

EDITリクエストされたPlanszaクラスコード全体をアップロードしました。

答えて

1

1つのオプションは、クラス

@XmlAccessorType(XmlAccessType.FIELD) 

に次の注釈を追加して、このような変数に@XmlElement注釈を移動するだろう。

@XmlElement 
String tura = null; 

そして、これはあなたのXMLを生成するために、注釈付きの変数を使用します

関連する問題