java - 将 twitter4J 状态保存到 MongoDB 会给出 "twitter4j.Status is an interface, and JAXB can' t 句柄接口(interface)”

标签 java mongodb jaxb twitter4j morphia

尝试保存List<Status>到 MongoDB(通过 Morphia),我得到这个编译时错误:

com.sun.xml.ws.spi.db.DatabindingException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
twitter4j.Status is an interface, and JAXB can't handle interfaces.
    this problem is related to the following location:
        at twitter4j.Status
        at public java.util.List Model.TwitterJob.getStatuses()

有什么想法吗?非常感谢!

最佳答案

编码(marshal) Status 有点复杂,因为在 Twitter4j 3.0 中实现 Status 的类 StatusJSONImpl 受到保护。 您需要重写该类并使其对您的类可见。

请查看以下示例以了解详细信息。

https://github.com/phstudy/Twitter4j_JAXB_example

关于java - 将 twitter4J 状态保存到 MongoDB 会给出 "twitter4j.Status is an interface, and JAXB can' t 句柄接口(interface)”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18490707/

相关文章:

java - Spring data jdbc 似乎不适用于最终属性

collections - Mongodb 自动写入上限集合

java - JOptionPane 对话框 - 存在额外行的问题

Java HEAD/GET 请求与 Linux 请求

node.js - NodeJS MongoDB : Multiple save requests not working

node.js - 如何在MongoDB中按日期查询文档?

java - 使用 JAXB 解码嵌套 XML 元素

maven - BadCommandLineException 与 maven cxf XJC 插件

java - 将 Spring Boot JMS 应用程序配置为默认使用 JAXB 编码的最简单方法是什么?

java - 但是,不应过度使用创建静态实用程序方法吗?如何避免呢?