[英]JAXB XML Unmarshalling creates xml classes's fields as well
I have an xml and and at that XML I have too many child fields such like . 我有一个xml,在那个XML上,我有太多子字段,例如。 From the documentation that I read, I see that JAXB auto generated xml to pojo classes but there is a remark there , JAXB can create fields as well ?
从我阅读的文档中,我看到JAXB自动将xml生成到pojo类,但是这里有一个说明,JAXB也可以创建字段吗? I meant do i have to create Employee class and its methods such like String job, String id myself or JAXB will create it themselves ?
我的意思是我必须创建Employee类,它的方法,例如String job,本人的String id还是JAXB自己创建? If my question is not clear, I can provide sample codes.
如果我的问题不清楚,我可以提供示例代码。
Cheers Alper 干杯Alper
<code>
<Employee>
<id>121</id>
<name>Alper</name>
</Employee>
</code>
Do I have to create String id; 我是否必须创建String id? String name;
字符串名称; as well ?
也一样?
You have 2 options: 您有2个选择:
But XML sample itself is not enough surely. 但是XML样本本身还不够可靠。
More information here: https://docs.oracle.com/javase/tutorial/jaxb/intro/examples.html 此处的更多信息: https : //docs.oracle.com/javase/tutorial/jaxb/intro/examples.html
you can generate POJO or java class from JAXB in eclipse, command line or maven. 您可以在Eclipse,命令行或Maven中从JAXB生成POJO或Java类。
you can file below several tutorials to learn this: 您可以通过以下几本教程来学习:
create POJO Class from XSD in Eclipse here 在这里从XSD在Eclipse中创建POJO类
create POJO class from XSD using command line here 使用命令行从XSD创建POJO类在这里
create POJO Class from XSD using XJC Maven Plugin here 使用XJC Maven插件XSD创建POJO类在这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.