Setter Injection
|
Constructor Injection
|
|||
1. If we have 3 dependencies like
int, string, long, then it’s not necessary to inject all values if we use
setter injection. If you are not inject it will takes default values for those
primitives
|
1. In constructor injection,
partial injection of dependencies cannot possible, because for calling
constructor we must pass all the arguments right, if not so we may get error
|
|||
|
|
|
||
2. Setter Injection will overrides the
constructor injection value, provided if we write setter and constructor
injection for the same property
|
2. But, constructor injection
cannot overrides the setter injected values
|
|||
|
|
|||
3. Setter injection makes bean
class object as mutable [We can change ]
|
3. Constructor injection makes
bean class object as immutable [We cannot change ]
|
|||