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

Disadvantages of the setter-based DI

Although the setter-based DI has higher priority than the constructor-based DI, the following are the disadvantages of the former:

  • There is no guarantee in a setter-based DI that the dependency will be injected.
  • One can use a setter-based DI to override another dependency. This can cause security issues in a Spring application.