[英]The type org.codehaus.jackson.JsonGenerationException cannot be resolved. It is indirectly referenced from required .class files
[英]The type com.fasterxml.jackson.core.JsonGenerator cannot be resolved. It is indirectly referenced from required .class files
在这里,我在我的 eclipse 项目中使用 Jackson data binder 2.4.1 jar 库将对象转换为 json 格式。 这是我的代码:
ObjectMapper mapper = new ObjectMapper();
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
mapper.writeValue(wr, content);
但在最后一行mapper.writeValue(wr, content);
它给出了一个错误说
The type com.fasterxml.jackson.core.JsonGenerator cannot be resolved. It is indirectly referenced from required .class files
我研究并发现,当一个 jar 文件的类依赖于另一个不可用的类时,就会发生这种类型的错误。 但是从我使用这个代码片段的地方来看,没有这样的问题。 但是我通过更改 JAR 版本失败了很多时间,但没有解决这个问题。 我该如何解决这个问题,请帮忙
您的类路径中需要jackson-databind
和jackson-core
。
除了 jackson-databind 之外,将jackson-core添加到您的类路径中。
脚步 :
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.