当前位置:网站首页>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 :
边栏推荐
- 从微服务基本概念到核心组件-通过一个实例来讲解和分析
- Online sql to XML tool
- The research group passed the thesis defense successfully
- 多御安全浏览器将改进安全模式,让用户浏览更安全
- Clickhouse填坑记2:Join条件不支持大于、小于等非等式判断
- FreeRTOS个人笔记-任务通知
- FreeRTOS personal notes - task notification
- Using RAC to realize the sending logic of verification code
- Antd setfieldsvalue warning problem cannot use 'setfieldsvalue' until you use 'getfielddecorator' or
- HDU 3078 network (lca+ sort)
猜你喜欢

PC端-bug记录

Duoyu security browser will improve the security mode and make users browse more safely

FreeRTOS learning (I)

Google browser cannot open localhost:3000. If you open localhost, you will jump to the test address
Printf function of input and output function in C language

Check box error

From the basic concept of micro services to core components - explain and analyze through an example

Database date types are all 0

MySQL(5)

Why is MD5 irreversible, but it may also be decrypted by MD5 free decryption website
随机推荐
【SLAM】LVI-SAM解析——综述
【ARXIV2205】EdgeViTs: Competing Light-weight CNNs on Mobile Devices with Vision Transformers
php7.1 连接sqlserver2008r2 如何测试成功
Testcafe's positioning, operation of page elements, and verification of execution results
DELL远程控制卡 使用ipmitools设置ipmi
[high CPU consumption] software_ reporter_ tool.exe
RT based_ Distributed wireless temperature monitoring system based on thread
PC side bug record
C language classic 100 question exercise (1~21)
Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)
Win10 machine learning environment construction pycharm, anaconda, pytorch
HDU 1530 maximum clique
测试开发---自动化测试中的UI测试
数据库日期类型全部为0
Gan: generative advantageous nets -- paper analysis and the mathematical concepts behind it
Applet import project
HDU 2586 How far away ? (LCA multiplication method)
How to simulate common web application operations when using testcafe
POJ 3728 the merchant (online query + double LCA)
HDU 3666 the matrix problemdifferential constraint + stack optimization SPFA negative ring