@JsonFilter throws “JsonMappingException: Can not resolve BeanPropertyFilter”

后端 未结 4 1270
無奈伤痛
無奈伤痛 2021-01-01 17:46

Is it possible to selectively determine when the @JsonFilter annotation gets used at runtime?

I\'m getting JsonMappingException exception (see below) when I don\'t p

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-01 17:58

    For Spring Boot / Jackson configuration just add:

    @Configuration 
    public class JacksonConfiguration { 
        public JacksonConfiguration(ObjectMapper objectMapper) { 
            objectMapper.setFilterProvider(new SimpleFilterProvider().setFailOnUnknownId(false)); 
        } 
    }
    

提交回复
热议问题