As of springboot 3.4, it has builtin support for that, by using @Bean(defaultCandidate=false)
@Bean(defaultCandidate=false)
see https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.4-Release-Notes#defining-additional-beans
Additionally, in this case, the type-based @Autowired needs changing. Otherwise it will inject the auto-configured one.
@Autowired