Bean wiring means configuring the beans along with its dependencies into on xml.
In bean wiring the programmer is responsible to configure all bean properties into xml file.
In case of auto wiring spring IoC container will automatically wire the dependencies which are in the form of objects. It means auto wiring is supported only for dependency in the form of objects but not primitives and collections.
4 Types of auto wirings are there
1. byName
2. byType
3. Constructor
4. Auto detect.
In bean wiring the programmer is responsible to configure all bean properties into xml file.
In case of auto wiring spring IoC container will automatically wire the dependencies which are in the form of objects. It means auto wiring is supported only for dependency in the form of objects but not primitives and collections.
4 Types of auto wirings are there
1. byName
2. byType
3. Constructor
4. Auto detect.
1)
|
byName
|
The
byName mode injects the object dependency according to name of the bean. In
such case, property name and bean name must be same. It internally calls
setter method.
|
2)
|
byType
|
In byType spring container verifies whether a bean class name configured in xml and the property type to be injected are matching or not. If matched then the container injects the class object by calling setter method of the class.
|
3)
|
constructor
|
The
constructor mode injects the dependency by calling the constructor of the
class. It calls the constructor having large number of parameters.
|
4)
|
Auto detect
|
It is
deprecated since Spring 3.
|
No comments:
Post a Comment