Constructor Injection |
Setter Injection |
1. Injecting bean properties through argumented constructor. |
1.Injecting bean properties through setter method.
|
2. It will first inject the bean dependencies then create the instance of current bean.
|
2. It will first create the bean instance and then inject the bean dependencies. |
3. Chance of forming Cyclic Dependency.
|
|
5. No chance of getting UnsatisfiedDependencyExeption. |
5. UnsatisfiedDependencyException in case of byType autowiring.
|
6. In case of Explicit Wiring, <constructor-arg/> tag is use to define this injection. |
6. <property/> tag s used to define this injection
|
7. In Cyclic Dependency , only one bean will be injecting by ignoring cyclic dependency. |
7. Doesn't form Cyclic Dependency, so both the bean will be injected successfully.
|
Tuesday, 8 April 2014
Difference between Construct and Setter Injection
Subscribe to:
Post Comments (Atom)
Check for the place to practice java interview questions through online.One click @ http://skillgun.com
ReplyDelete