package wrapper;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
//import GameOfLife;
/**
* Helper class to wrap a list of persons. This is used for saving the
* list of persons to XML.
*
* @author Marco Jakob
*/
@XmlRootElement(name = "games")
public class GameWrapper {
//
// private GameOfLife game123;
private GameOfLife games;
@XmlElement(name="game")
public GameOfLife getGames(){
return games;
}
// public List<Person> getPersons() {
// return persons;
// }
public void setGame123(GameOfLife gameOfLife) {
this.games = gameOfLife;
}
}
报错是:com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
类的两个属性具有相同名称 "generation"
this problem is related to the following location:
at public int wrapper.GameOfLife.getGeneration()
at wrapper.GameOfLife
at public wrapper.GameOfLife wrapper.GameWrapper.getGames()
at wrapper.GameWrapper
this problem is related to the following location:
at public int wrapper.GameOfLife.generation
at wrapper.GameOfLife
at public wrapper.GameOfLife wrapper.GameWrapper.getGames()
at wrapper.GameWrapper
XmlRootElement定义根节点要素的同时也定义了GameWrapper的别名为games,而GameWrapper内也有一个属性名为GameWrapper,在不设置别名的情况下默认以属性名作为xml节点名。此时转换过程中就会由两个games节点,产生异常
您好,我是有问必答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~
如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~
ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632