It should be possible with @Qualifier e.g.: so
@Bean(autowireCandidate = false, defaultCandidate = false)
@Qualifier("myBean")
public MyBeanClass myBean() {
return new MyBeanClass();
}
@Bean
public MyAnotherBean myAnotherBean(@Qualifier("myBean") MyBeanClass myBean) {
return new MyAnotherBean(myBean);
}
You can find more information about @Qualifier here:
https://docs.spring.io/spring-framework/reference/core/beans/annotation-config/autowired-qualifiers.html