Class has two properties of the same name "elementList" this problem is related to the following location: at public java.util.List com.jaxb.tieba.JaxbList.getElementList() at com.jaxb.tieba.JaxbList this problem is related to the following location: at private java.util.List com.jaxb.tieba.JaxbList.elementList at com.jaxb.tieba.JaxbList
如果将注解加到 field 上面 将会报出一个如下异常
@XmlRootElement public class JaxbList<T> { @XmlElement(name="elments") private List<T> elementList = new ArrayList<T>(); public List<T> getElementList() { return elementList; } }
本文讨论了一个Java类中出现两个相同名称属性elementList的问题,其中一个为私有字段,另一个为公共方法。当使用JAXB进行XML序列化时,这种设置会导致错误。文章通过具体代码示例展示了如何定位和解决这一问题。
3160

被折叠的 条评论
为什么被折叠?



