【发布时间】:2014-12-18 07:33:00
【问题描述】:
我正在尝试运行此代码:
JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
Tags tags = (Tags) unmarshaller.unmarshal(new File("Tags.xml"));
但是,我得到了这个错误:
javax.xml.bind.UnmarshalException:意外元素(uri:“”,本地:“标签”)。预期的元素是(无)
如何防止发生此异常?这是我的根元素:
@XmlRootElement(name = "tags")
【问题讨论】:
-
您是从 XML Schema 生成模型的吗?
-
我对此很天真,我点击了这个链接:youtube.com/watch?v=4J_ytgQ96Kg 并做了它所拥有的一切
标签: xml jaxb unmarshalling