[英]JsonMappingException: No suitable constructor found for type [simple type, class com.fasterxml.jackson.databind.node.ObjectNode]
I have read JSONMappingException for External Object , JSONMappingException for Class but can't found solution for ObjectNode
class. 我已经读过外部对象的 JSONMappingException,类的JSONMappingException,但找不到ObjectNode
类的解决方案。
By Reading JSONMappingException for External Object I understand that you have to register Object in mapper but I have not created any ObjectMapper class as I am calling web service 通过读取外部对象的JSONMappingException我明白你必须在mapper中注册Object但是我没有创建任何ObjectMapper类,因为我正在调用Web服务
mapper.registerModule(new GeoModule());
I am trying to call web service of My POJO ( ReportQueryData.java
) which contain ObjectNode
(com.fasterxml.jackson.databind.node.ObjectNode) instance variable. 我试图调用包含ObjectNode
(com.fasterxml.jackson.databind.node.ObjectNode)实例变量的My POJO( ReportQueryData.java
)的Web服务。
ReportQueryData.java ReportQueryData.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;
}
}
Now I am calling web service containing ReportQueryData in request and I am facing below exception 现在我在请求中调用包含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)
You have to write default constructor for this class also like this 您必须为此类编写默认构造函数,如下所示
public ReportQueryData (){
}
Edit: : try to wrap that class in your and use your class. 编辑::尝试将该课程包装在您的课程中并使用您的课程。
class A{
A(String s){
}
}
class B extends A{
B(){
super("str");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.