![Hands-On High Performance with Spring 5](https://wfqqreader-1252317822.image.myqcloud.com/cover/793/36699793/b_36699793.jpg)
上QQ阅读APP看书,第一时间看更新
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.