org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type

org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type

 

org.codehaus.jackson.map.JsonMappingException: No suitable constructor found  for type [simple type,  class test.jackson.Employee]: can not instantiate from JSON object (need to add/enable type information?)
  at [Source: c:\temp\employee.json; line:  1 , column:  2 ]
     at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java: 163 )
     at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java: 483 )
     at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java: 350 )
     at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java: 2395 )
     at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java: 1549 )
     at test.jackson.JSONToJavaExample.main(JSONToJavaExample.java: 19 )

通常來講,解決上面問題從下面幾個方面入手:java

一、是否缺乏默認構造函數json

二、是不是類的訪問修飾符問題,即jackson訪問不到。app

相關文章
相關標籤/搜索