【发布时间】:2018-12-23 05:06:50
【问题描述】:
我尝试使用 android studio 生成 XML 文件,但出现此错误:
Caused by: javax.xml.datatype.DatatypeConfigurationException: Provider org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl not found.
问题来自“JAXBContext”行。 我有一个使 XML 文件的代码为的函数
try {
File file = new File("D:\\Github\\Comedu\\file.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(Resultat.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// output pretty printed
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(this, file);
jaxbMarshaller.marshal(this, System.out);
} catch (JAXBException e) {
e.printStackTrace();
}
在 android studio 上,我将 xerces 包添加到我的构建路径中,所以我不知道如何解决这个问题。
【问题讨论】: