Google News
logo
Full Stack Developer - Interview Questions
What are the differences between constructor injection and setter injection?
Constructor Injection Setter Injection
There is no partial injection of dependencies. There can be a partial injection of dependencies.
It does not override the setter injection value. It overrides the constructor injection value if both are defined.
It always creates a new instance if any modification occurs. It does not create a new instance if we made any changes to it.
Using constructor injection is better for too many properties. Using setter injection is better for few properties.
It makes bean class objects as immutable. It makes bean class objects as mutable.
Advertisement