概念:dependency injection, ioc, vs callback.

 

callback function as a dependency of the object that it is being passed into. DI is the process of providing the callback (the dependency) to the object. (For example: by giving it to the object via its constructor, a method call, a setter, etc.).

翻译: callback是具体的依赖, DI是注入依赖的过程

 

DI是IoC的子集

 

IoCI nversion o f C ontrol ): - 这是一个通用术语,以多种方式实现(事件,代理等)。

DID ependency I njection): - DI是IoC的子类型,通过构造函数注入,setter注入或接口注入实现

但是,Spring仅支持以下两种类型:

 

Powered by Jekyll and Theme by solid

本站总访问量