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

后端 未结 4 1938
无人共我
无人共我 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:22

    Easy annotation driven solution. In a @Configuration:

    @Bean
    @Primary
    public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
        ObjectMapper objectMapper = builder.createXmlMapper(false).build();
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
        return objectMapper;
    }
    

提交回复
热议问题