我已经阅读了 External Object的JSONMappingException 和 Class的 JSONMappingException 但找不到ObjectNode
类的解决方案。
通过阅读外部对象的 JSONMappingException, 我了解到您必须在映射器中注册对象,但我没有创建任何 ObjectMapper 类,因为我正在调用 Web 服务
mapper.registerModule(new GeoModule());
我正在尝试调用ReportQueryData.java
包含ObjectNode
(com.fasterxml.jackson.databind.node.ObjectNode) 实例变量的 My POJO ( ) 的 Web 服务。
报告查询数据.java
import com.fasterxml.jackson.databind.node.ObjectNode;
public class ReportQueryData {
private ObjectNode parentsData;
public ObjectNode getParentsData() {
return parentsData;
}
public void setParentsData(ObjectNode parentsData) {
this.parentsData = parentsData;
}
}
现在我在请求中调用包含 ReportQueryData 的 Web 服务,我面临以下异常
org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type [simple type, class com.fasterxml.jackson.databind.node.ObjectNode]: can not instantiate from JSON object (need to add/enable type information?)
[INFO] [talledLocalContainer] at [Source: org.apache.catalina.connector.CoyoteInputStream@3da45801; line: 1, column: 155] (through reference chain: com.atlassian.qtm.model.ReportQueryData["parentsData"])
[INFO] [talledLocalContainer] at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163)
[INFO] [talledLocalContainer] at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObjectUsingNonDefault(BeanDeserializer.java:740)
[INFO] [talledLocalContainer] at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:683)