Saturday, January 4, 2014

Spring Course: V9 Dependency Injection

Dependency Injection

As we mentioned before, we can do Dependency Injection either by <constractor-arg> or <property>, so either by the constructor or by the set method.

Here we will talk about how we inject a bean to another bean

1- we have an address class.

2- now we define a person class which has an address.

3- now in beans.xml we define Address bean and Person bean, we inject address in person by using ref attribute.

No comments:

Post a Comment