Autowiring
==============================================================\
When we declare a class as bean as part of spring bean configuration file,then IOC containe will not managed the dependency between the classes,until we have to provide the dependency between those classes.
But we dont want to manually provide the dependency rather we have to instruct the IOC to detect the dependenct and managed the injection.
<bean id="motor" class="com.di.Motor" autowire="byName"> </bean>
-> Configuring beans and their dependency is nothing but wiring.
-> There are two types of wiring. 1. Explicit wiring, and 2. Autowiring(Implicit wiring).
-> Autowiring feature of Spring f/w enables us to inject the object dependency implicitly.
-> It internally uses setter or constructor injection.
-> It requires the less code because we don't need to write the code to inject the dependency explicitly.
-> Autowiring can't be used to inject premitive and string values. It works with reference only.
-> There is no control of programmer. This is disadvantage of autowiring.
->There are many autowiring modes.
1. byName
2. byType
3. constructor
4. autodetect
5. no
Example: <bean id="motor" class="com.di.Motor" autowire="byName"> </bean>
==============================================================\
When we declare a class as bean as part of spring bean configuration file,then IOC containe will not managed the dependency between the classes,until we have to provide the dependency between those classes.
But we dont want to manually provide the dependency rather we have to instruct the IOC to detect the dependenct and managed the injection.
<bean id="motor" class="com.di.Motor" autowire="byName"> </bean>
-> Configuring beans and their dependency is nothing but wiring.
-> There are two types of wiring. 1. Explicit wiring, and 2. Autowiring(Implicit wiring).
-> Autowiring feature of Spring f/w enables us to inject the object dependency implicitly.
-> It internally uses setter or constructor injection.
-> It requires the less code because we don't need to write the code to inject the dependency explicitly.
-> Autowiring can't be used to inject premitive and string values. It works with reference only.
-> There is no control of programmer. This is disadvantage of autowiring.
->There are many autowiring modes.
1. byName
2. byType
3. constructor
4. autodetect
5. no
Example: <bean id="motor" class="com.di.Motor" autowire="byName"> </bean>
Comments
Post a Comment