当前位置:网站首页>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 :
边栏推荐
- POJ 2763 housewife wind (tree chain partition + edge weighting point weight)
- MySQL(5)
- Testcafe's positioning, operation of page elements, and verification of execution results
- C language: addition and deletion of linked list in structure
- Online sql to XML tool
- POJ 3417 network (lca+ differential on tree)
- RT_ Use of thread message queue
- 【ARXIV2203】Efficient Long-Range Attention Network for Image Super-resolution
- Specific differences between typedef and define
- HDU 2874 connections between cities
猜你喜欢

FreeRTOS startup process, coding style and debugging method
![[high CPU consumption] software_ reporter_ tool.exe](/img/3f/2c1ecff0a81ead0448e1215567ede7.png)
[high CPU consumption] software_ reporter_ tool.exe

Online sql to XML tool

Bean的作用域、执行流程、生命周期

【ARIXV2204】Neighborhood attention transformer

【ARXIV2203】Efficient Long-Range Attention Network for Image Super-resolution

ES6 new variable modifiers let and const, new basic data type symbol

How practical is the struct module? Learn a knowledge point immediately

Data security is gradually implemented, and we must pay close attention to the source of leakage

Mysql基本查询
随机推荐
MySQL 默认隔离级别是RR,为什么阿里等大厂会改成RC?
MySQL(5)
Struct模块到底有多实用?一个知识点立马学习
面试了一位38岁程序员,听说要加班就拒绝了
Implementation of simple upload function in PHP development
How should programmers keep warm when winter is coming
FreeRTOS personal notes - task notification
Table image extraction based on traditional intersection method and Tesseract OCR
FreeRTOS learning (I)
Gym 101911c bacteria (minimum stack)
11.< tag-动态规划和子序列, 子数组>lt.115. 不同的子序列 + lt. 583. 两个字符串的删除操作 dbc
Online sql to XML tool
Simulink automatically generates STM32 code details
Dcgan:deep volume general adaptive networks -- paper analysis
【ARXIV2203】SepViT: Separable Vision Transformer
Classes and objects [medium]
How to successfully test php7.1 connecting to sqlserver2008r2
HDU 3666 the matrix problemdifferential constraint + stack optimization SPFA negative ring
HashSet add
Interpretation of afnetworking4.0 request principle