[英]can anyone please tell me what is the difference between Inversion of Control (IOC) and Dependency Injection (DI) in spring?
I'am seriously figuring out this for the last one week and continuously keep on reading articles and blogs so that I can understand the difference in the very leman language and terms so that I can understand easily!!!!!在过去的一周里,我认真地弄清楚了这一点,并不断地阅读文章和博客,以便我能够理解非常简单的语言和术语的差异,以便我能够轻松理解!!!!!!
Dependency injection is simply about depending on an abstract interface and passing a concrete implementation of that interface to your class through the constructor or a setter method.依赖注入只是依赖于一个抽象接口,并通过构造函数或 setter 方法将该接口的具体实现传递给您的 class。 This allows you to use a different concrete implementation without changing your class. This is useful, for instance for testing.
这允许您在不更改 class 的情况下使用不同的具体实现。这很有用,例如用于测试。
IoC is also known as the Hollywood principle: don't call us, we call you. IoC也被称为好莱坞原则:不要打电话给我们,我们打电话给你。 In this case a framework defines an interface and the application provides the concrete implementation.
在这种情况下,框架定义接口,应用程序提供具体实现。 This helps to limit dependencies between classes.
这有助于限制类之间的依赖关系。 IoC is often implemented using dependency injection, but it's not a hard requirement.
IoC 通常使用依赖注入来实现,但这并不是硬性要求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.