【发布时间】:2020-08-21 14:16:41
【问题描述】:
我想使用 JAXB 序列化一个对象。我的类定义如下所示:
@XmlRootElement
public class MyClass{
<<How do I annotate this one?>>
private xyz_type xyz;
@XmlElement(name = "unique")
private int unique;
}
public class xyz_type extends abc_type{
private qwe_tpe qwe;
public static final ert_type ARRAY = ert_type.ARRAY;
}
提前感谢您的帮助!
【问题讨论】:
-
问题是什么?怎么了?你期望什么,你得到什么?
-
可以添加
@XmlElement(name = "xyz", required = true)private xyz_type xyz;之类的注解 -
@GigaKokaia 我的 xml 文件中只列出了原始数据类型。
-
@SanthoshKThadka 我试过了,但它不起作用。
-
字段有getter,需要序列化吗?
标签: java xml-parsing jaxb xml-serialization