无法解析 com.fasterxml.jackson.core.JsonGenerator 类型.它是从所需的 .class 文件间接引用的 [英] The type com.fasterxml.jackson.core.JsonGenerator cannot be resolved. It is indirectly referenced from required .class files
问题描述
这里我在我的 eclipse 项目中使用 Jackson 数据绑定器 2.4.1 jar 库将对象转换为 json 格式.这是我的代码:
Here I am using Jackson data binder 2.4.1 jar library in my eclipse project to convert an object to a json format. And here is my code:
ObjectMapper mapper = new ObjectMapper();
DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
mapper.writeValue(wr, content);
但在最后一行 mapper.writeValue(wr, content);
它给出了一个错误说
but in the last line mapper.writeValue(wr, content);
it gives an error saying
The type com.fasterxml.jackson.core.JsonGenerator cannot be resolved. It is indirectly referenced from required .class files
我研究发现,当一个 jar 文件的类依赖于另一个不可用的类时,就会发生这种类型的错误.但是从我使用这个代码片段的地方来看,没有这样的问题.但是我通过更改 JAR 版本失败了很多时间,但没有解决这个问题.我该如何解决这个问题,请帮忙
I have studied and found that when a jar file's class is dependent on another class which is unavailable then this type of error occurs. But from where I am using this code snippet there is no issue like this. But I have failed a lot of time by changing the JAR version but nothing solved this issue. How can I solve this, please help
推荐答案
您的类路径中需要 jackson-databind
和 jackson-core
.
You need both jackson-databind
and jackson-core
on your classpath.
这篇关于无法解析 com.fasterxml.jackson.core.JsonGenerator 类型.它是从所需的 .class 文件间接引用的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!