Quick revision
The short answer
Defining an ObjectMapper bean makes JacksonAutoConfiguration back off, so Boot's own mapper, its defaults such as WRITE_DATES_AS_TIMESTAMPS being disabled, and every spring.jackson.* property stop applying. To add one module, the developer should register the module as a bean, which Boot adds to its mapper automatically, or use a Jackson2ObjectMapperBuilderCustomizer. Replacing an auto-configured bean should be a deliberate, documented choice.
What to remember
In this answer, we saw that Boot builds its ObjectMapper only when we have not defined one, so a custom ObjectMapper bean makes JacksonAutoConfiguration back off and takes Boot's defaults and every spring.jackson property with it. Dates turned into numbers because plain Jackson writes them as timestamps. The fix is to register the module as a bean or use a builder customizer, and to override auto-configured beans only when we must, with the reason written down.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Defining an ObjectMapper bean makes JacksonAutoConfiguration back off, so Boot's own mapper, its defaults such as WRITE_DATES_AS_TIMESTAMPS being disabled, and every spring.jackson.* property stop applying. To add one module, the developer should register the module as a bean, which Boot adds to its mapper automatically, or use a Jackson2ObjectMapperBuilderCustomizer. Replacing an auto-configured bean should be a deliberate, documented choice.
Why this question is asked
This is a classic code review moment. The change looks tiny and harmless: one bean, one module. Yet other teams see dates turn into numbers and their properties stop working, in code they did not touch. Interviewers like it because it tests whether we understand how auto-configuration backs off, not just how to use Jackson. In this answer, we will recap how Boot configures Jackson, reproduce what the new bean did, explain why the properties stopped working, and then look at the right ways to add a module and what to say in the review.
1A Quick Recap of How Boot Configures Jackson
Spring MVC turns our objects into JSON with an ObjectMapper, Jackson's main class for reading and writing JSON. Spring Boot does not leave that mapper to Jackson's defaults. JacksonAutoConfiguration builds it through a Jackson2ObjectMapperBuilder, applies every spring.jackson.* property, registers well-known modules such as the Java time module, and changes a few defaults. The most visible one is that Boot disables WRITE_DATES_AS_TIMESTAMPS, so dates are written as ISO strings like "2026-11-05", and it disables FAIL_ON_UNKNOWN_PROPERTIES.
The ObjectMapper bean in that configuration is annotated with @ConditionalOnMissingBean. That means: create this bean only if the application has not defined its own. This is how auto-configuration lets us take over, and it is also the trap in this question.
2Reproducing What the New Bean Did
Here is the kind of change the developer made, to add a money module for a custom Money type.
The money field works, which is all the developer tested. But the date changed from a string to an array of numbers, because a plain new ObjectMapper() has WRITE_DATES_AS_TIMESTAMPS enabled. Properties that other teams set in their services, such as the inclusion rule or a date format, are now ignored, because nothing reads them any more. And since the bean came from a shared configuration library, every service that uses it changed at once.
3Why the Properties Stopped Working
The spring.jackson.* properties are not read by Jackson. They are read by Boot's auto-configuration, which copies them into the builder that creates Boot's mapper. When our bean exists, @ConditionalOnMissingBean fails, Boot's mapper is never created, and so the properties have nowhere to go. Nothing fails at startup; the properties are simply unused.
- Context finds our ObjectMapper beandefined in
JsonConfig - Boot evaluates JacksonAutoConfiguration
@ConditionalOnMissingBean(ObjectMapper) - Is an ObjectMapper already defined?YesBack off: no Boot mapperNoBuild Boot's mapper
- spring.jackson.* propertiesread only by Boot's builder, so unused
- Spring MVC uses our plain mapperJackson defaults, dates as numbers
5 steps in order. Play them, or step through them one at a time.
We can see the back-off in the condition evaluation report: the ObjectMapper bean method of JacksonAutoConfiguration appears under negative matches with a message saying it found an existing bean of type ObjectMapper. That is a quick way to prove the cause in the review.
4Fix 1: Register the Module as a Bean
The simplest fix is to not touch the ObjectMapper at all. Boot collects every bean of type com.fasterxml.jackson.databind.Module and registers it on the mapper it builds.
Notice what changed: we no longer compete with Boot for the ObjectMapper. Boot still builds it, applies every property, keeps its defaults, and simply adds our module. Other teams' configuration keeps working because it never stopped being read.
5Fix 2: Use a Builder Customizer for Other Settings
When we need more than a module, such as enabling a feature for everyone, Boot offers Jackson2ObjectMapperBuilderCustomizer. It receives Boot's builder after the properties are applied, so we change one thing and keep the rest.
A word on versions: Spring Boot 4 moves to Jackson 3 by default, where the packages and builder customizer types are different and some defaults changed, so check your version for the exact names. The principle is the same in both: customize Boot's builder instead of replacing its mapper.
6What to Say in the Code Review
The review comment should explain the cause, not just ask for a change: the new bean makes JacksonAutoConfiguration back off, which drops Boot's defaults and all spring.jackson properties for every service using this library. Then suggest the module bean, and ask for a test that serializes a LocalDate and checks the string, so the contract is protected next time.
The broader rule is to override auto-configured beans only when we truly must, and when we do, to write down why, in the code and in the library's release notes. Overriding is a supported feature of Boot, but every override turns off a whole set of behaviour that readers of the code cannot see.
7Follow-up questions
How can I check whether my bean made an auto-configuration back off?
Start the application with --debug or read the conditions actuator endpoint. Look for the auto-configured bean method under negative matches; the message names the condition, such as @ConditionalOnMissingBean, and the existing bean it found.
Is it ever right to define my own ObjectMapper bean?
Yes, when the application needs settings that Boot's model cannot express and we accept owning all of them. Even then, building it from the injected Jackson2ObjectMapperBuilder keeps the properties and modules. If we need a second mapper for one purpose, giving it a qualifier and leaving the primary one to Boot avoids the back-off.
Why did only the dates change and not the money field?
Because the money module was registered explicitly, while date handling depended on defaults that Boot sets and plain Jackson does not. The bug lives in everything the developer did not configure, which is why it was missed in testing.
8Conclusion
In this answer, we saw that Boot builds its ObjectMapper only when we have not defined one, so a custom ObjectMapper bean makes JacksonAutoConfiguration back off and takes Boot's defaults and every spring.jackson property with it. Dates turned into numbers because plain Jackson writes them as timestamps. The fix is to register the module as a bean or use a builder customizer, and to override auto-configured beans only when we must, with the reason written down.
Open with
I would explain the cause first. Boot's ObjectMapper is created by JacksonAutoConfiguration with @ConditionalOnMissingBean, so as soon as we define our own ObjectMapper bean, Boot's one is not created.
Then, if they want more
The spring.jackson properties are read by that auto-configuration, not by Jackson, so they stop applying, and Boot's defaults go too, like WRITE_DATES_AS_TIMESTAMPS being disabled. That is exactly why dates became arrays of numbers. I can prove it in the conditions report, where the ObjectMapper bean shows as a negative match because an existing bean was found.
Then I would suggest the fix: just declare the module as a bean. Boot registers every Module bean on the mapper it builds, so we get the money module and keep all the defaults and properties.
If they need other settings, a Jackson2ObjectMapperBuilderCustomizer changes Boot's builder without replacing it, and if a separate mapper is truly needed, it should be built from the injected builder. On Boot 4 the Jackson 3 types have different names, but the idea is the same.
I would also ask for a test that serializes a LocalDate, and as a general rule, override auto-configured beans only when necessary and document why.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- 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 "A developer defines a custom ObjectMapper bean to add one module, and other teams report...": https://scrivio-interview-library.netlify.app/spring-boot/auto-configuration/9c113bdd52/