简体   繁体   English

需要JAXB项目帮助

[英]JAXB project help needed

I need help with this issue in JAXB , while I run the project I always got the error below 我在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

This is my code: 这是我的代码:

/*
 * 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 + '}';
    }
}

Okay. 好的。 This is why they say - follow standard and conventions . 这就是为什么他们说- follow standard and conventions

Problem is - you have member variable names capitalized. 问题是-您将成员变量名称大写。

Change them to something like - "id", "assignment", "midTerm", "quiz", "classLab" and it should work. 将它们更改为类似"id", "assignment", "midTerm", "quiz", "classLab" ,它应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM