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 https://github.com/spring-projects/spring-framework/issues/33762. As such, we should wait until after 3.4.0-RC1 and moving onto Framework snapshots before updating our docs.

Comment From: wilkinsona

There's going to be a 6.2.0-RC3 of Framework and we've already moved to snapshots so we can now do this one whenever we're ready.