当前位置:网站首页>What is dependency injection (DI)
What is dependency injection (DI)
2022-07-07 05:35:00 【PIKapikaaaa】
DI The full name is Dependency Injection, It's called dependency injection in Chinese .
It is related to the reversal of control (IoC) It means the same thing , It's just that these two terms describe the same concept from two perspectives . For one Spring For beginners , These two terms are difficult to understand , Now we will describe these two concepts in simple language .
When a Java object ( caller ) You need to call another Java object ( Callees , That is, the dependent object ) when , In the traditional mode , Callers usually use “new Callees ” Code to create objects , Pictured 1 Shown . This approach will lead to increased coupling between the caller and the callee , It is not conducive to the upgrading and maintenance of later projects .
chart 1 The caller creates the callee object
In the use of Spring After the framework , An instance of an object is no longer created by the caller , But by the Spring Container to create ,Spring The container is responsible for controlling the relationship between programs , Instead of being directly controlled by the caller's program code . such , Control has shifted from application code to Spring Containers , There is a reversal of control , This is it. Spring The reversal of control .
from Spring From the perspective of containers ,Spring The container is responsible for assigning the dependent object to the caller's member variable , This is equivalent to injecting the caller with the instance it depends on , This is it. Spring Dependency injection of , Pictured 2 Shown .
chart 2 Inject the callee object into the caller object
边栏推荐
- Zero sequence aperture of leakage relay jolx-gs62 Φ one hundred
- Getting started with DES encryption
- 照片选择器CollectionView
- Leetcode (417) -- Pacific Atlantic current problem
- 常用消息队列有哪些?
- 高级程序员必知必会,一文详解MySQL主从同步原理,推荐收藏
- Make web content editable
- Under the trend of Micah, orebo and apple homekit, how does zhiting stand out?
- 论文阅读【Sensor-Augmented Egocentric-Video Captioning with Dynamic Modal Attention】
- [JS component] date display.
猜你喜欢
基于NCF的多模块协同实例
Record a pressure measurement experience summary
EGR-20USCM接地故障继电器
High voltage leakage relay bld-20
C#可空类型
高压漏电继电器BLD-20
消息队列:如何确保消息不会丢失
Jhok-zbg2 leakage relay
Flink SQL realizes reading and writing redis and dynamically generates hset key
论文阅读【Open-book Video Captioning with Retrieve-Copy-Generate Network】
随机推荐
A cool "ghost" console tool
一条 update 语句的生命经历
The year of the tiger is coming. Come and make a wish. I heard that the wish will come true
Make web content editable
JHOK-ZBL1漏电继电器
Flink SQL realizes reading and writing redis and dynamically generates hset key
淘宝店铺发布API接口(新),淘宝oAuth2.0店铺商品API接口,淘宝商品发布API接口,淘宝商品上架API接口,一整套发布上架店铺接口对接分享
High voltage leakage relay bld-20
JVM(十九) -- 字节码与类的加载(四) -- 再谈类的加载器
Mysql database learning (7) -- a brief introduction to pymysql
TabLayout修改自定义的Tab标题不生效问题
app clear data源码追踪
设f(x)=∑x^n/n^2,证明f(x)+f(1-x)+lnxln(1-x)=∑1/n^2
Is the human body sensor easy to use? How to use it? Which do you buy between aqara green rice and Xiaomi
Reading the paper [sensor enlarged egocentric video captioning with dynamic modal attention]
导航栏根据路由变换颜色
京东商品详情页API接口、京东商品销量API接口、京东商品列表API接口、京东APP详情API接口、京东详情API接口,京东SKU信息接口
Writing process of the first paper
论文阅读【MM21 Pre-training for Video Understanding Challenge:Video Captioning with Pretraining Techniqu】
漏电继电器LLJ-100FS