当前位置:网站首页>详解三级缓存解决循环依赖
详解三级缓存解决循环依赖
2022-06-10 19:29:00 【-隐函数-】
循环依赖
所谓的循环依赖就是
A对象创建的时候需要通过@Autowired依赖注入B对象才能创建成功,B对象创建的时候需要@Autowired依赖注入A对象才可以创建成功,这种情况之下,我们称之为循环依赖,循环依赖主要发生在Bean的set赋值这个过程
其实@Autowired就已经解决了循环依赖的问题
缓存

三级缓存解决循环依赖

我们以A对象为例,A对象通过BeanFunctionRead读取配置文件,利用反射机制进行实例化创建之后,因为此时没有赋值初始化等,还不是一个完整的bean所以无法放进一级缓存,先放入三级缓存之中,
然后调用Autowired注解进行属性的赋值,发现B对象还没有创建出来,先暂停,准备创建B对象
B对象利用反射机制实例化之后也放进三级缓存当中,然后进行Autowired注解进行属性赋值,
发现需要A注解,那么从一、二、三 级缓存当中依次去寻找,发现三级缓存当中存在A注解,那么就调用ObjectFactory中的getObject方法进行调用,然后B把A放进二级缓存中,B进行赋值
然后执行其他阶段,直至把B创建出来放进一级缓存当中,之后清空二三缓存
B创建成功之后,A可以获取B就可以继续进行创建,然后A开始进行Autowired注解进行赋值,然后继续执行其他阶段,然后A对象创建成功,放进一级缓存当中,同时清空二三缓存
边栏推荐
- HW blue team intermediate interview reply
- Solution to the problem that JLINK CDC UART driver cannot be installed normally under win7 system
- Looking for a room in the graduation season of college students, VR panoramic viewing helps you screen Online
- How to stack double and float in the bottom layer of C language
- 零信任架构
- Analysis on rendering principle of mobile terminal
- Soft deletion of data - when? How to realize it?
- KP522201A采用 SOT23-6 封装的 4.5V 至 17V 输入、2A 输出、600kHz 同步降压转换器
- ESP8266 系统环境搭建
- First batch! Sinomenine has passed CWPP capability assessment and inspection of Xintong Institute
猜你喜欢

HW blue team intermediate interview reply

Bit operation topic

Solution to the problem that JLINK CDC UART driver cannot be installed normally under win7 system

hidden danger? Limited meaning? Can't stop the real cooking Mini kitchenware hot 618

Basic instructions for ads and AXD

Mysql database foundation

推开混合云市场大门,Lenovo xCloud的破局之道

FPGA state machine
![[observation] shengteng Zhixing: scene driven, innovation first, press the](/img/53/29f5fd8b869087bafbe74849329c84.jpg)
[observation] shengteng Zhixing: scene driven, innovation first, press the "acceleration key" for Intelligent Transportation

传音 Infinix 新机现身谷歌产品库,TECNO CAMON 19 预装 Android 13
随机推荐
Key points of lldp protocol preparation
NFS network mount to create server image
Open the door of the hybrid cloud market, Lenovo xcloud's way to break the situation
FS4100 锂电充电管理IC输入12V给8.4V充电IC
uni-app自定义导航
ResourceNotFoundException : Unable to find resource
[FAQ] summary of common problems and solutions during the use of rest API interface of sports health service
企业级存储发展趋势谈:开源存储的冷思考
SBC chip 35584 data manual pre regulator translation
Analysis on rendering principle of mobile terminal
推开混合云市场大门,Lenovo xCloud的破局之道
It took 2 years, 442 authors and 132 institutions! Google released the new benchmark big bench for language model evaluation. 204 tasks comprehensively evaluated the language model ability, with paper
HM3416H降压IC芯片PWM/PFM 控制 DC-DC 降压转换器
Tutoriel Microsoft Word "5", comment changer les marges de page et créer une barre de nouvelles en word?
JD released ted-q, a large-scale and distributed quantum machine learning platform based on tensor network acceleration
最近的工作
How to add independent hotspots in VR panoramic works?
vulnhub-The Planets: Earth
table设置超出部分隐藏,鼠标移上去显示全部
今年高考期间各考点秩序井然,未发生影响安全的敏感案事件