繁体   English   中英

将twitter4J Status保存到MongoDB会得到“ twitter4j.Status是一个接口,而JAXB无法处理接口”

[英]saving twitter4J Status to MongoDB gives “twitter4j.Status is an interface, and JAXB can't handle interfaces”

尝试将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()

任何想法? 非常感谢!

StatusJSONImpl Status有点复杂,因为在Twitter4j 3.0中实现Status的类StatusJSONImpl受到保护。 您需要覆盖该类并使它对您的类可见。

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

https://github.com/phstudy/Twitter4j_JAXB_example

您可以使用@XmlElement批注指定Status接口的实现类。

@XmlElement(type=SomeStatusImpl.class)
public List<Status> getStatuses() {
    return statuses;
}

欲获得更多信息

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM