What are the differences between constructor injection and setter injection?

devquora
devquora

Posted On: Feb 22, 2018

 

The difference between Constructor Injection and Setter Injection are:
  • In constructor injection, there’s no partial injection while setter injection provides for partial injection.
  • Constructor injection overrides the setter property while setter injection overrides the constructor property.
  • Constructor injection creates a new instance for any kind of modification while setter injection doesn’t.
  • Constructor injection works better for many properties while setter injection works better for few properties.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Spring Interview Questions

    What are the features/ characteristics of spring?

    The important features of spring are as follows:Lightweight: Considering transparency and size, spring is lightweight..

    Spring Interview Questions

    How many types of modules are there in spring? Name them.

    There are around twenty modules, which can be categorized into Core Container, Web, Data Access or Integration, Aspect ..

    Spring Interview Questions

    What do you mean by Spring Java Based Configuration?

    Spring configuration files are XML files. These files contain the information of classes and describe how these classes..