The method I updated provides an ObjectMapper bean that can be injected elsewhere. But the method is annotated with @Primary and @ConditionalOnMissingBean. I think these two should never be used together.
I removed the @Primary annotation on the method.
Comment From: pivotal-cla
@Erates Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
Comment From: pivotal-cla
@Erates Thank you for signing the Contributor License Agreement!
Comment From: bclozel
@Primary and @ConditionalOnMissingBean. I think these two should never be used together.
Applications can still use ObjectProvider or qualifiers to get a specific bean, even if primary is being used.
I'm sorry but we need to decline this change as removing this now would break existing applications relying on this behavior.
Comment From: Erates
@primary and @ConditionalOnMissingBean. I think these two should never be used together.
Applications can still use
ObjectProvideror qualifiers to get a specific bean, even if primary is being used.I'm sorry but we need to decline this change as removing this now would break existing applications relying on this behavior.
@bclozel I agree for Spring Boot 2.x, but can't this behaviour change be implemented in 3.x?
Comment From: bclozel
We're trying to make the upgrade experience as smooth as possible and right now I don't think this change is worth it given its potential disruption and the lack of value for developers.
If we remove that @Primary annotation, how would developers get the ObjectMapper they're customizing through configuration properties?
Comment From: Erates
In my opinion it would make it easier to the developers. Now when I need to change the behaviour of the ObjectMapper I always have to add @Primary or use the @Qualifier like you said.
I think it will be easier for the developer that he can inject an ObjectMapper and not configure it yourself if the default is fine, or create a bean yourself if the default implementation is not OK.
Comment From: bclozel
When the behavior of the ObjectMapper needs customizing, Spring Boot is providing many ways to contribute and configure the behavior, hopefully this should cover quite a lot of cases.
Comment From: Erates
Ok I see.
Thanks for looking into it though!