无法解析类型com.fasterxml.jackson.core.JsonGenerator。 它是从所需的.class文件间接引用的
这里我在我的eclipse项目中使用Jackson数据绑定器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
。