Skip to content

Clarify why @Primary is recommended when defining your own ObjectMapper that replaces JacksonAutoConfiguration's #42598

@pratyakshajha

Description

@pratyakshajha

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:
image
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions