Why does this work:
@Configuration
public class MyConfig {
@Bean
public A getA() {
return new A();
}
@Bean // <-- Shouldn\'t I
Hi Jan your question is marked as answered over 4 years ago but I've found a better source: https://www.logicbig.com/tutorials/spring-framework/spring-core/javaconfig-methods-inter-dependency.html
here's another article with the same idea: https://dzone.com/articles/spring-configuration-and, it also states that such usage is not well documented which I found true. (?)
so basically if beanA's initialization depends on beanB, spring will wire them without explicit @Autowired annotation as long as you declare these two beans in the application context (i.e. @Configuartion class).