search
HomeJavaJavaBaseWhat does dependency injection mean?

What does dependency injection mean?

Jun 29, 2020 pm 03:30 PM
dependency injection

Dependency injection means that when the program is running, if you need to call another object for assistance, you do not need to create the callee in the code, but rely on external injection. Spring's dependency injection has a negative impact on the caller and the callee. The caller has almost no requirements and fully supports the management of dependencies between POJOs.

What does dependency injection mean?

#Spring can effectively organize objects at each layer of J2EE applications. Whether it is an Action object in the control layer, a Service object in the business layer, or a DAO object in the persistence layer, they can all be coordinated and run organically under Spring's management. Spring organizes objects at each layer together in a loosely coupled manner. Action objects do not need to care about the specific implementation of Service objects. Service objects do not need to care about the specific implementation of persistence layer objects. The calls to objects at each layer are completely interface-oriented. When the system needs to be refactored, the amount of code rewriting will be greatly reduced.

Everything mentioned above is suitable for Spring's core mechanism, dependency injection. Dependency injection allows beans to be organized together through configuration files instead of being coupled together in a hard-coded manner. Understand dependency injection.

Dependency Injection and Inversion of Control are the same concept. The specific meaning is: When a role (perhaps a Java instance, the caller) needs the assistance of another role (another Java instance, the callee), in the traditional programming process, it is usually created by the caller An instance of the callee. But in Spring, the work of creating the callee is no longer done by the caller, so it is called inversion of control; the work of creating the callee instance is usually done by the Spring container, and then injected into the caller, so it is also called dependency injection.

Whether it is dependency injection or inversion of control, it shows that Spring uses a dynamic and flexible way to manage various objects. The specific implementations between objects are transparent to each other.

Recommended tutorial: "java tutorial"

The above is the detailed content of What does dependency injection mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software