Below should be possible sequence
beanbstarts to get autowired- During class initialization of
Beanb, beana starts to get autowired - Once beana gets created the
@PostConstructi.e.init()of beana gets called - Inside
init(),System.out.println("bean a is called");gets called - Then
b.printMe();gets called causingSystem.out.println("print me is called in Bean B");to execute - Having the
beanacompleted the@PostConstructi.e.init()ofbeanbgets called - Then
System.out.println("beanb is called");gets called
Ideally the same can be better observed by a debugger in eclipse.
The Spring reference manual explains how circular dependencies are resolved. The beans are instantiated first, then injected into each other.