Spring Boot: Auto-configuration backs off when you define your own bean

@ConditionalOnMissingBean means your bean wins; the starter only fills in what you did not supply.

Code
// Spring Boot would auto-configure an ObjectMapper. Define one and yours is used:
@Configuration
class JacksonConfig {
    @Bean
    ObjectMapper objectMapper() {
        return JsonMapper.builder()
                .addModule(new JavaTimeModule())
                .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
                .build();
    }
}
Output
Boot's JacksonAutoConfiguration is annotated @ConditionalOnMissingBean,
so it steps aside and your ObjectMapper is the one injected everywhere.
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-11