需要JAXB项目帮助

时间:2016-04-11 17:10:45

标签: java jaxb

我需要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 + '}';
    }
}

1 个答案:

答案 0 :(得分:0)

好。这就是为什么他们说 - follow standard and conventions

问题是 - 您将成员变量名称大写。

将它们更改为 - "id", "assignment", "midTerm", "quiz", "classLab",它应该有用。