I am using SpringBoot 3.1.5 with Spring Boot starter web and validation.

When I try to set the properties spring.jackson.deserialization.fail-on-unknown-properties to false in application.yml SpringBoot spring.jackson.deserialization.fail-on-unknown-properties Not Working And hit the controller with the json payload with an extra attribute "account", it is still throwing the JSON parsing error SpringBoot spring.jackson.deserialization.fail-on-unknown-properties Not Working But if I add the annotation @JsonIgnoreProperties(ignoreUnknown = true) directly to the model class, then the API works as expected.

Is there something that I am missing? Or is it an issue with the configuration not being recognized?

Comment From: wilkinsona

We have a test for disabling fail-on-unknown-properties:

https://github.com/spring-projects/spring-boot/blob/5ff4a961b131a32c3b6417a4ebd0e55fe8d1a504/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfigurationTests.java#L206-L215

There's no known reason for it not to work as long as your application is using the auto-configured ObjectMapper. Perhaps something has defined an ObjectMapper bean that means the auto-configuration has backed off?

If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: zengshengliu

I did setup a separate object mapper with a different bean name

    @Bean(name = "SQSObjectMapper")
    public ObjectMapper sqsObjectMapper() {
        var javaTimeModule = new JavaTimeModule();
        return new ObjectMapper().registerModule(javaTimeModule);
    }

and use it on a separate service

    @Qualifier("SQSObjectMapper")
    private final ObjectMapper objectMapper;

I didn't realize that will also override the auto-configured object mapper. After removing the block for testing, the configuration seems to be working now.

Is it possible to create a custom object mapper without it affecting the auto-configured one?

Comment From: zengshengliu

I found my own answer. Since Jackson auto configuration one is using @ConditionalOnMissingBean, any additional bean of ObjectMapper will cause the auto-configured one to not trigger. In order to solve it, I have to define a separate object mapper as @Primary with the Jackson configuration, and keep the second one above. Thanks.

Comment From: wilkinsona

Is it possible to create a custom object mapper without it affecting the auto-configured one?

Yes, but it would have to be defined in your own auto-configuration class that is ordered after JacksonAutoConfiguration.