Advantages of the constructor-based DI

The following are the advantages of a constructor-based DI in your Spring application:

  • It's suitable for mandatory dependencies. In a constructor-based DI, you can be sure that the object is ready to be used the moment it is constructed.
  • The code structure is very compact and clear to understand.
  • When you need an immutable object then, through constructor-based dependency, you can ensure you get the immutable nature of the object.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset