Scrivio Interview library
ConceptFoundations5 min read · updated 12 November 2026

What does 'auto-configuration backs off' mean? Give an example with ObjectMapper or DataSource.

Backing off means that an auto-configured bean steps aside when we define our own bean of the same type. Boot guards most auto-configured beans with @ConditionalOnMissingBean, so if we declare an ObjectMapper or a DataSource @Bean, Boot's version is never created. The catch is that Boot's properties, such as spring.jackson.* or spring.datasource.*, were applied by the bean we replaced, so they stop working; to adjust Boot's bean rather than replace it, we use a customizer such as Jackson2ObjectMapperBuilderCustomizer.

Why this question is asked

Back-off is the reason Spring Boot can give us a working application without taking control away. It is also behind a common surprise: someone adds a small ObjectMapper bean to change one setting, and suddenly every spring.jackson property in the project is ignored and dates are serialised as numbers. Interviewers ask this to check that we understand what our own beans do to Boot's. In this answer, we will recap how auto-configured beans are guarded, see back-off happen with ObjectMapper, look at the same effect with a DataSource, and then use customizers to change Boot's beans without replacing them.

1A Quick Recap: Conditions on Auto-Configured Beans

An auto-configuration is a configuration class that Boot loads from its own jars, after our configuration, and every bean in it is guarded by conditions. The most important one is @ConditionalOnMissingBean: create this bean only if the context does not already contain a bean of this type.

Because Boot evaluates auto-configurations after it has read all our @Configuration classes and component scan results, our beans are already registered when that condition is checked. So our bean wins, and Boot's bean is skipped. That is what backs off means: Boot's default steps back to make room for ours.

Java
// simplified from Boot's Jackson auto-configuration
@Bean
@Primary
@ConditionalOnMissingBean // skipped if any ObjectMapper bean already exists
ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
return builder.createXmlMapper(false).build(); // the builder carries spring.jackson.* settings
}

Notice where the properties come in. Boot builds its ObjectMapper from a Jackson2ObjectMapperBuilder, and that builder is where every spring.jackson setting is applied. If the bean is skipped, the builder's settings are never used for it.

2Example: Replacing ObjectMapper

Suppose application.properties says spring.jackson.serialization.write-dates-as-timestamps=false, so dates are written as ISO strings. Then a developer wants unknown JSON fields ignored and adds a bean.

Java
@Configuration
class JsonConfig {
@Bean
ObjectMapper objectMapper() {
return new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
}
// before: {"createdAt":"2026-11-05T10:15:00Z"}
// after: InvalidDefinitionException: Java 8 date/time type java.time.Instant not supported by default
// after adding findAndRegisterModules(): {"createdAt":1793873700.000000000} spring.jackson.* still ignored
Step throughHow Boot decides on ObjectMapper
  1. User configuration registeredour @Bean ObjectMapper, if any
  2. JacksonAutoConfiguration evaluatedruns after user configuration
  3. ObjectMapper bean already defined?@ConditionalOnMissingBean
    YesBack off: ours is used, spring.jackson.* not appliedNoCreate Boot's mapper with spring.jackson.*

3 steps in order. Play them, or step through them one at a time.

Notice that the new bean is a plain ObjectMapper. Boot's auto-configured one registered the Jackson modules found on the classpath, such as the Java time module, and applied every spring.jackson property. Our bean has none of that, so it cannot even write an Instant until we register the module, and then it writes numbers because the date setting is gone, and because it exists, Boot backs off completely. Spring MVC's message converters then use our bare mapper for every request and response.

Defining a Jackson2ObjectMapperBuilder bean of our own has a similar effect one level up: Boot's builder, which reads spring.jackson properties, backs off.

3The Same Effect With DataSource

DataSourceAutoConfiguration creates a connection pool, HikariCP by default, from spring.datasource.url, username, password and the spring.datasource.hikari.* settings. It is guarded by @ConditionalOnMissingBean on DataSource. If we declare our own DataSource bean, Boot backs off, and none of those properties reach our pool unless we bind them ourselves.

Java
@Bean
DataSource dataSource() {
HikariDataSource ds = new HikariDataSource();
ds.setJdbcUrl("jdbc:postgresql://db:5432/shop");
return ds; // spring.datasource.hikari.maximum-pool-size=30 is now ignored: pool size 10
}
// Keep the properties working by binding them to our bean:
@Bean
@ConfigurationProperties("spring.datasource.hikari")
HikariDataSource dataSource(DataSourceProperties props) {
return props.initializeDataSourceBuilder().type(HikariDataSource.class).build();
}

The second form is how Boot's documentation suggests defining a DataSource by hand while keeping the property support: DataSourceProperties still reads spring.datasource.*, and @ConfigurationProperties binds the Hikari settings onto our pool. A second DataSource, for example a reporting database, is the usual reason to do this at all.

4Adjust, Do Not Replace: Customizers

Most of the time we do not want a different bean; we want Boot's bean with one change. For that, Boot offers customizer interfaces. A customizer is a bean that Boot calls while it builds its own object, so Boot keeps creating the bean, applies the properties, and then lets us adjust it.

Java
@Bean
Jackson2ObjectMapperBuilderCustomizer ignoreUnknown() {
return builder -> builder.failOnUnknownProperties(false);
}
// {"createdAt":"2026-11-05T10:15:00Z"} spring.jackson.* still applied, unknown fields ignored

Notice that nothing backs off here, because we did not define an ObjectMapper. Several customizers can coexist, each changing one thing, which keeps the change small and easy to review. Boot has the same pattern elsewhere, with WebServerFactoryCustomizer, RestClientCustomizer, RestTemplateCustomizer, ThreadPoolTaskExecutorCustomizer and many more.

In Spring Boot 4, the default JSON library is Jackson 3, whose mapper type is tools.jackson.databind.json.JsonMapper, and the matching customizer is JsonMapperBuilderCustomizer; the back-off rule is the same. Check your version for the exact names.

5Follow-up questions

How can you see that a bean backed off?

Run with debug=true or use Actuator's conditions endpoint. In the condition evaluation report, JacksonAutoConfiguration's jacksonObjectMapper appears under negative matches with a message saying that @ConditionalOnMissingBean found an existing bean named objectMapper.

Does every auto-configured bean back off?

Most do, but the conditions differ. Some back off only for a bean with a specific name, as RedisTemplate does with name = "redisTemplate", and a few are designed to be combined rather than replaced, such as the lists of customizers and converters. The source or the report tells us which condition applies.

When is replacing the bean the right choice?

When we truly need a different object, for example two DataSources, or an ObjectMapper configured for a special purpose. Even then, it is often better to add a second, qualified bean for the special case and leave Boot's primary one in place.

6Conclusion

In this answer, we saw that auto-configured beans are guarded by @ConditionalOnMissingBean and evaluated after our configuration, so our own bean makes Boot's back off. With ObjectMapper and DataSource that also switches off the related spring.jackson and spring.datasource properties, unless we bind them ourselves, and customizers such as Jackson2ObjectMapperBuilderCustomizer let us adjust Boot's bean instead of replacing it.

What to say in the interviewAbout 80 seconds aloud

Open with

Backing off means an auto-configured bean steps aside when I've defined my own bean of that type. Boot evaluates auto-configurations after all my configuration, and most auto-configured beans are guarded by @ConditionalOnMissingBean, so if my bean is already there, Boot's is never created.

Then, if they want more

The classic example is ObjectMapper. Boot builds its mapper from a Jackson2ObjectMapperBuilder, which is where all the spring.jackson properties and the registered modules are applied.

If someone adds a plain ObjectMapper @Bean just to ignore unknown properties, Boot backs off, and suddenly spring.jackson settings like writing dates as ISO strings stop applying, because the bean that used them no longer exists.

DataSource works the same way: define your own and spring.datasource and the Hikari properties no longer reach the pool, unless you bind them with DataSourceProperties and @ConfigurationProperties. So when I only want to adjust Boot's bean, I don't replace it; I use a customizer. For Jackson that's a Jackson2ObjectMapperBuilderCustomizer bean that, say, turns off failOnUnknownProperties.

Boot still creates its mapper, applies all properties, and then calls my customizer. In Boot 4 with Jackson 3 the equivalent is JsonMapperBuilderCustomizer. If I'm unsure whether something backed off, the condition evaluation report shows it under negative matches.

About this answer

Last updated
12 November 2026
Versions it names
Java 8, Spring Boot 4
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring Boot reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What does 'auto-configuration backs off' mean? Give an example with ObjectMapper or...": https://scrivio-interview-library.netlify.app/spring-boot/auto-configuration/1e353ad78d/