1.

Explain the difference between constructor and setter injection?

Answer»
  • In constructor injection, partial injection is not ALLOWED whereas it is allowed in setter injection.
  • The constructor injection doesn’t override the setter property whereas the same is not true for setter injection.
  • Constructor injection creates a NEW instance if any modification is done. The creation of a new instance is not possible in setter injection.
  • In case the BEAN has many properties, then constructor injection is preferred. If it has few properties, then setter injection is preferred.


Discussion

No Comment Found