private static final int TYPE = 2;
@XmlElement(name = "type")
public static int getTYPE() {
return TYPE;
}
这是完全错误的,@XmlElement(name = “type”) 注解应该用于实例方法,而不是静态方法。对于静态字段,JAXB 无法直接进行注解处理,因为静态字段是与类关联而不是与对象关联的。
解决方法:建个其他非静态方法
private static final int TYPE = 2;
public static int getTYPE() {
return TYPE;
}
@XmlElement(name = "type")
public int getType() {
return TYPE;
}