Skip to content

Update documentation where we recommend a @Qualifier on one bean and @Primary on another to suggest a single bean with defaultCandidate=false #42831

@wilkinsona

Description

@wilkinsona

Framework 6.2 has introduced support for @Bean(defaultCandidate=false) which allows a bean to be declared such that it can only be injected where further constraints, such as a qualifier, are specified.

There are places in the documentation where we currently recommend declaring one bean with @Primary and a second bean with a qualifier, for example when configuring a Batch data source using @BatchDataSource or a Batch transaction manager using @BatchTransactionManager. We should review such documentation and consider recommending a single bean with both the qualifier and @Bean(defaultCandidate=false). A benefit of this over the current recommendation is that it allows any auto-configured bean of the same type to remain in place.

Note that the defaultCandidate=false approach won't work until we've upgraded to Framework 6.2.0 due to spring-projects/spring-framework#33762. As such, we should wait until after 3.4.0-RC1 and moving onto Framework snapshots before updating our docs.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions