Spring control inversion and dependency injection

Source: Internet
Author: User


(1) Why use control inversion and dependency injection

The caller does not have to care about the callee's implementation, and it does not require the caller to create the callee's instance personally, which is given to the framework to complete.

This design idea is control inversion (inversion of control, IoC), and it has another name that is dependency injection (Dependency injection, DI).

(2) What is control inversion and dependency injection

The control reversal (IOC) is controlled by the "dependencies between objects" that are programmed by the program, and the caller's instance creation work is no longer done by the caller.

Yes. Control inversion enables you to control the relationships between classes in an application by an external container. With control inversion, the callee is "injected" rather than hard-coded into

In the caller's code, this can greatly reduce the dependency between the caller and the callee.


Dependency Injection is another name for control inversion, which has the same meaning. Their essence is to change the "dependencies between objects" to rely on the IOC container.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.