spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Spring Boot is not respecting Jackson configuration

Open mozzer39 opened this issue 3 weeks ago • 2 comments

I have a problem with setting a deserialization feature in Jackson 3. With Jackson 3 there's a change in behavior while mapping null values into primitive types. I created a configuration class, but unfortunately it's not working and I still get error while deserialization. What am I missing?

@Configuration
public class JsonMapperConfig {

    @Bean
    @Primary
    JsonMapperBuilderCustomizer jacksonCustomizer() {
        return builder -> builder.disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES);
    }

}

The error I'm getting:

Caused by: tools.jackson.databind.exc.MismatchedInputException: Cannot map `null` into type `int` (set DeserializationConfig.DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES to 'false' to allow)
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); byte offset: #766] (through reference chain: xxx)

mozzer39 avatar Dec 03 '25 08:12 mozzer39

@mozzer39 it's impossible to say with a few lines of code in text. We don't know how it's being used or how the configuration arrangement works.

If you want support, please take the time to build a small sample, starting from start.spring.io and share it with us with instructions to reproduce that exception. You can attach a zip here or push the code to a GitHub repository.

snicoll avatar Dec 03 '25 09:12 snicoll

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues avatar Dec 10 '25 09:12 spring-projects-issues