java - 如何解决由 JAXB 语句引起的异常?
问题描述
这是我试图运行的代码,但它目前在这一行抛出异常:
try {
File file = new File(getFilesDir().getPath() + "/" + name + ".xml");
JAXBContext jaxbContext = JAXBContext.newInstance(Restaurant.class);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(r, file);
} catch (JAXBException e) {
e.printStackTrace();
}
我在这一行抛出了一个异常:
JAXBContext jaxbContext = JAXBContext.newInstance(Restaurant.class);
我将日志复制到 pastebin ( https://pastebin.com/WRjXbub7 )
我正在尝试将对象序列化为 XML 文件。我的代码中没有出现红色标记或任何内容,所以我不知道这里有什么问题。谢谢!
解决方案
推荐阅读
- spring - 安装后无法构建 JHipster 项目
- swift - 顶部的 NSImageView 防止 NSDataPicker 获得焦点
- reactjs - 反应自动路线问题
- angular - 带有嵌入 else 模板的自定义 ngIf 指令
- angular - Angular + Nativescript 代码共享项目移除操作栏
- android - NFC 到 BT/BLE 与 Android 9 的切换现在阻止 MAC 地址检索
- wpf - WPF WebBrowser禁用浏览器中网页的鼠标事件?
- cakephp - CakePHP:从 $Auth->user() 到达相关表
- python - RegEx 用于在最后一个连字符之前提取一定数量的字符
- git - 特拉维斯:不要在某些工作中克隆