当前位置:网站首页>Scope, execution process and life cycle of bean
Scope, execution process and life cycle of bean
2022-07-28 05:20:00 【Mei on the hill】
Catalog
1.Bean Scope ( Very important , The interview will take )
1.2Bean Of 6 Planting ⽤ Domain
2.Bean Of board ⾏ technological process
3.Bean ⽣ Life cycle ( It is divided into 5 Parts of )
1.Bean Scope ( Very important , The interview will take )
1.1Bean Scope definition
Bean Works of ⽤ Domain means Bean stay Spring Something in the whole framework ⾏ For mode
1.2Bean Of 6 Planting ⽤ Domain
1. singleton( yes Bean The default scope for )
The book ⽤ Under domain Bean stay IoC Only exist in container ⼀ An example : obtain Bean( That is, through applicationContext.getBean etc. ⽅ Can't get ) And assembly Bean( That is, through @Autowired notes ⼊) It's all the same ⼀ Objects , So when other ⼈ After changing this value , So another way ⼀ individual ⼈ What you read is the modified value
Use scenarios : Usually ⽆ State of Bean(Bean The property state of the object does not need to be updated ) send ⽤ The book ⽤ Domain
Look at one other ⼈ After changing this value , So another way ⼀ individual ⼈ What you read is the case of the modified value :

2. prototype
Every time I do ⽤ Under domain Bean All requests will create new instances : obtain Bean( Instant communication applicationContext.getBean etc. ⽅ Can't get ) And assembly Bean( That is, through @Autowired notes ⼊) Are all new object instances .
Usage scenario : Usually stateful Bean(Bean The property state of the object needs to be updated ) send ⽤ The book ⽤ Domain
give an example :

3. request
Every time http The request creates a new Bean example , Be similar to prototype
Use scenarios :⼀ Time http Sharing of requests and responses Bean
4. session
stay ⼀ individual http session in , Definition ⼀ individual Bean example
Use scenarios :⽤ Sharing of user replies Bean, ⽐ Such as : Record ⼀ individual ⽤ Login information of the user
5. application
stay ⼀ individual http servlet Context in , Definition ⼀ individual Bean example
Use scenarios :Web Should be ⽤ Up and down ⽂ Information ,⽐ Such as : Record ⼀ One should ⽤ Share information for
6. websocket
stay ⼀ individual HTTP WebSocket Of ⽣ In the life cycle , Definition ⼀ individual Bean example
Use scenarios :WebSocket In every conversation , Save the ⼀ individual Map Structure header information , take ⽤ To wrap client messages
head . The first ⼀ After the first initialization , until WebSocket The end is the same ⼀ individual Bean
1.2.1 A single example is ⽤ Domain (singleton) Work with the overall situation ⽤ Domain (application) difference
1. The difference between acting on :singleton yes Spring Core Works of ⽤ Domain ,application yes Spring Web The works in the book ⽤ Domain
2. The difference between containers :singleton do ⽤ On IoC The container of ,⽽ application do ⽤ On Servlet Containers .
2.Bean Of board ⾏ technological process
start-up Spring Containers -> Instantiation Bean( Allocate memory space , from ⽆ To have )-> Bean Sign up to Spring in ( Save operation ) -> take Bean Assemble into the required class ( Take operation )
3.Bean ⽣ Life cycle ( It is divided into 5 Parts of )
⽣ Life cycle refers to ⼀ Objects from birth ⽣ To destroy the whole ⽣ Life process

Life cycle Demo :
边栏推荐
- HDU 3592 World Exhibition (differential constraint)
- What is the reason why the easycvr national standard protocol access equipment is online but the channel is not online?
- Specific differences between typedef and define
- Know etcd
- Interpretation of afnetworking4.0 request principle
- Redux basic syntax
- C language classic 100 question exercise (1~21)
- Array or object, date operation
- Service object creation and use
- 11.< tag-动态规划和子序列, 子数组>lt.115. 不同的子序列 + lt. 583. 两个字符串的删除操作 dbc
猜你喜欢

基于MPLS构建虚拟专网的配置实验

Simulink automatically generates STM32 code details

【ARXIV2204】Simple Baselines for Image Restoration

阿里怎么用DDD来拆分微服务?

RT based_ Distributed wireless temperature monitoring system of thread (I)

Win10 machine learning environment construction pycharm, anaconda, pytorch

FreeRTOS personal notes - task notification

Gan: generative advantageous nets -- paper analysis and the mathematical concepts behind it

【ARXIV2204】Vision Transformers for Single Image Dehazing

【CVPR2022 oral】Balanced Multimodal Learning via On-the-fly Gradient Modulation
随机推荐
RT_ Use of thread mailbox
Supervisor series: 5. Log
为什么md5不可逆,却还可能被md5免费解密网站解密
7.<tag-字符串和API的取舍>补充: 剑指 Offer 05. 替换空格
Introduction to testcafe
Evolution of ape counseling technology: helping teaching and learning conceive future schools
Duoyu security browser will improve the security mode and make users browse more safely
Clickhouse填坑记2:Join条件不支持大于、小于等非等式判断
Bean的作用域、执行流程、生命周期
Know etcd
Testcafe provides automatic waiting mechanism and live operation mode
Internal implementation principle of yymodel
类和对象【中】
HDU 2874 connections between cities
Simulink automatically generates STM32 code details
11. < tag dynamic programming and subsequence, subarray> lt.115. Different subsequences + Lt. 583. Deletion of two strings DBC
【ARIXV2204】Neighborhood attention transformer
Why is MD5 irreversible, but it may also be decrypted by MD5 free decryption website
Paper reading notes -- crop yield prediction using deep neural networks
Share several methods of managing flag bits in C program