@JsonIgnoreProperties(ignoreUnknown=false) is not working in Spring 4.2.0 and upper version

后端 未结 4 1942
无人共我
无人共我 2020-12-21 05:24

@JsonIgnoreProperties(ignoreUnknown=false) is not working with spring 4.2.0 and upper version of spring. But it is working with 4.0.4 and 4.0.1 . I am using spring 4.2.8 and

4条回答
  •  佛祖请我去吃肉
    2020-12-21 06:17

    This is happening because the HttpMessageConverter provided by the earlier versions of spring were using ObjectMapper default configuration. But the newer versions of spring use Jackson2ObjectMapperBulider which has DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES property set to false by default. (Reference link). You can solve this issue by adding the following in your applicationContext.xml:

    
    
    
        
            
                
            
        
    
    
        
        
            
                json=application/json
            
        
    
    

提交回复
热议问题