ben oliver wrote: In this case, in class A, so I do not need to instantiate B b = new B(), right ? I can just use "b" directly since I have defined it in the <bean> section, right ? Is this the only benfit in this case ?
Yes, you can use "b" directly because it is in the bean.xml. This is true regardless of whether you do so using your approach or Nathan's. Nathan's is a bit clearer to me since it shows nobody else is using "b".
ben oliver wrote:second question --- when the 2nd time class A is invoked, is that "b" the same instance when Class A is invoked ? what's the life cycle of this "b" ?
Yes. By default the scope is "singleton" on a Spring bean which means you get the same instance throughout the application.