The JacksonAutoConfiguration class takes care of creating a default ObjectMapper bean. The conditions based on which this configuration gets applied can be documented in a better way. For example, Spring docs link is confusing. As per this, both @Bean and @Primary are needed to replace the default ObjectMapper: SpringBoot Clarify why @Primary is recommended when defining your own ObjectMapper that replaces JacksonAutoConfiguration's In reality, the @Primary is not necessary, just creating a ObjectMapper bean results in the default jackson ObjectMapper bean not being created. This can result in problems as described in #22403.

This behaviour should be mentioned clearly in the documentation. Also, the Javadoc for JacksonAutoConfiguration states this behaviour and this clarity should be present in the documentation as well.

Comment From: wilkinsona

Annotating the @Bean method with @Primary is recommended by the documentation as the auto-configured ObjectMapper is @Primary. In other words, if you want your custom ObjectMapper to be a drop-in replacement for the auto-configuration's, it should be @Primary. This allows it to be the preferred choice when there are multiple ObjectMapper beans in the context as is quite often the case.

We can update the docs to try to make this more clear.