Hands-On High Performance with Spring 5
上QQ阅读APP看书,第一时间看更新

Advantages of the setter-based DI

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

  • It's more readable than the constructor injection.
  • This is useful for non-mandatory dependencies.
  • It solves the circular dependency problem in the application.
  • It helps us to inject the dependency only when it is required.
  • It's possible to reinject dependencies. It is not possible in a constructor-based injection.