http://www.cnblogs.com/davidwang456/p/5434071.html

*********************************************

 

有时候,如果数据库表中增加一个字段,但返回的JSON字符串中含有我们并不需要的字段,那么当对应的实体类中不含有该字段时,会抛出一个异常,告诉你有些字段没有在实体类中找到。解决办法很简单,在声明ObjectMapper之后,加上上述代码:

objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

     java.lang.Object
        java.lang.Enum<DeserializationFeature>
            com.fasterxml.jackson.databind.DeserializationFeature

FAIL_ON_UNKNOWN_PROPERTIES

Feature that determines whether encountering of unknown properties (ones that do not map to a property, and there is no "any setter" or handler that can handle it) should result in a failure (by throwing a JsonMappingException) or not.
 

 

 

有时候,如果数据库表中增加一个字段,但返回的JSON字符串中含有我们并不需要的字段,那么当对应的实体类中不含有该字段时,会抛出一个异常,告诉你有些字段没有在实体类中找到。解决办法很简单,在声明ObjectMapper之后,加上上述代码:

objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

     java.lang.Object
        java.lang.Enum<DeserializationFeature>
            com.fasterxml.jackson.databind.DeserializationFeature

FAIL_ON_UNKNOWN_PROPERTIES

Feature that determines whether encountering of unknown properties (ones that do not map to a property, and there is no "any setter" or handler that can handle it) should result in a failure (by throwing a JsonMappingException) or not.
 

 

 

相关文章:

  • 2022-12-23
  • 2021-06-08
  • 2018-04-06
  • 2021-05-24
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-05
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
相关资源
相似解决方案