簡體   English   中英

需要JAXB項目幫助

[英]JAXB project help needed

我在JAXB需要有關此問題的幫助,而在我運行項目時,總是出現以下錯誤

Property assignment is present but not specified in @XmlType.propOrder
this problem is related to the following location: 
  at public int edu.asu.cse446.sample1.server.test.GradBook.getAssignment()
  at edu.asu.cse446.sample1.server.test.GradBook

這是我的代碼:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates     
 * and open the template in the editor.
 */

 package edu.asu.cse446.sample1.server.test;

 /**
  *
  * @author luayalmamury
  */
 /*
  * To change this license header, choose License Headers in Project Properties.
  * To change this template file, choose Tools | Templates
  * and open the template in the editor.
  */

 /**
  *
  * @author luayalmamury
  */



 @XmlRootElement
 @XmlType(propOrder={
    "id",
    "Assignment",
    "MidTerm",
    "Quiz",
    "ClassLab"})

public class GradBook {

    private static final Logger LOG = LoggerFactory.getLogger(GradBook.class);

    private int id;
    private int Assignment;
    private int MidTerm;
    private int  Quiz;
    private int ClassLab;

    public GradBook(){
        LOG.info(" Creating Student Grade Object");
    }

    public int getId() {
        return id;
    }

    @XmlAttribute           // Read it in XML Format
    public void setId(int id) {
         LOG.info(" Setting Student Id", id);
         this.id=id;
         LOG.debug(" Update Student Id",this);
    }

    public int getAssignment() {
        return Assignment;
    }

    @XmlElement             
    public void setAssignment(int Assignment) {
        LOG.info(" Create Student Assignment",Assignment);
                    this.Assignment=Assignment;
                    LOG.debug("Update Student Assignment",this);
    }

    public int getMidTerm() {
        return MidTerm;
    }

    @XmlElement                 // Read it in XML Format
    public void setMidTerm(int MidTerm) {
        LOG.info(" Create Student MidTerm ",MidTerm);
                    this.MidTerm=MidTerm;
                    LOG.debug("Update Student MidTerm ",this);
    }

    public int getQuiz() {
        return Quiz;
    }

    @XmlElement                 // Read it in XML Format
    public void setQuiz(int Quiz) {
        LOG.info(" Create Student Quiz",Quiz);
                    this.Quiz=Quiz;
                    LOG.debug("Update Student Assignment",this);
    }

    public int getClassLab() {
        return ClassLab;
    }

    @XmlElement                 // Read it in XML Format
    public void setClassLab(int ClassLab) {
        LOG.info(" Create Class Lab",ClassLab);
                    this.ClassLab=ClassLab;
                    LOG.debug("Update Student Class Lab",this);
    } 

    @Override
    public String toString() {
        return "GradeBook{" + "id=" + id + ", Assignment=" + Assignment +  ",MidTerm=" + MidTerm   + " Quiz=" + Quiz  + ", ClassLab=" + ClassLab + '}';
    }
}

好的。 這就是為什么他們說- follow standard and conventions

問題是-您將成員變量名稱大寫。

將它們更改為類似"id", "assignment", "midTerm", "quiz", "classLab" ,它應該可以工作。

暫無
暫無

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

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