例如,假设您想要使用构造函数为calculator bean注入必需的依赖关系(必需的SCA引用)。
For example, assume you're trying to inject the required dependencies (the required SCA references) for the calculator bean using the constructor.
这个行为在DI世界中称作构造函数注入,因为实例是通过一个构造函数传递的。
This behavior is referred to in the DI world as constructor injection, because the instance is passed through one of the constructors.
Spring中的构造函数注入允许您通过类构造函数注入依赖关系。
Constructor injection in Spring lets you inject your dependencies through class constructors.
应用推荐