I have read Spring boot doc (http://projects.spring.io/spring-boot/docs/docs/howto.html#message.converters ) and its mentioned that if you provide your own JacksonConvertor, it will override the default one. But I guess its not working with the below code.
What I want to do is to set DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES of the object mapper to false.
@EnableAutoConfiguration
@ComponentScan("com.hjh")
@Configuration
public class App {
@Bean
@Primary
public MappingJackson2HttpMessageConverter jacksonConvertor(){
MappingJackson2HttpMessageConverter convertor= new MappingJackson2HttpMessageConverter();
ObjectMapper mapper = new ObjectMapper();
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
convertor.setObjectMapper(mapper);
return convertor;
}
public static void main(String[] args) throws Exception {
ApplicationContext ctx = SpringApplication.run(App.class, args);
}
Could any one please point out what am i doing wrong here? As it keeps on trying to bind the unknown prop from the request. If I remove the unknown prop, it all goes well
Starting from Spring Boot 1.2.0.RC2 FAIL_ON_UNKNOWN_PROPERTIES
is set to false
by default. It can be turned back on by adding property to application.properties
:
spring.jackson.deserialization.fail-on-unknown-properties=true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With