请选择 进入手机版 | 继续访问电脑版

湖南新梦想

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 276|回复: 0

Bean的生命周期

[复制链接]

33

主题

33

帖子

190

积分

注册会员

Rank: 2

积分
190
发表于 2022-12-28 22:13:43 | 显示全部楼层 |阅读模式
Bean的生命周期(bean的创建到bean的销毁的过程就叫生命周期)
Bean的生命周期的11个步骤:
1.instantiate bean对象实例化
2.populate properties封装属性
3如果Bean实现BeanNameAware执行setBeanName
4.如果Bean实现BeanFactoryAware或者ApplicationContextAware设置厂setBeanFactory
或者下文对象setApplicationContext
5.如果存在类实现BeanPostProcessor (后处理Bean),执行postProcessBeforelnitialization
6.如果Bean实现InitializingBean执行afterPropertiesSet
7.调用<bean init-method="init">指定初始化方法init
8.如果存在类实现BeanPostProcessor (处理Bean), 执行postProcessAfterlnitialization
9执行业务处理
10.如果Bean实现DisposableBean执行destroy
11.调用<bean destroy-method="customerDestroy">指定销毁方法customerDestroy在
CustomerService类的add方法之前进行权限校验?
总结: bean的四大主生命周期: bean实例化(new)--->bean填充属性(设置属性值)
bean初始化(对象bean前期处理)--- >bean销毁




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|湖南新梦想 ( 湘ICP备18019834号-2 )

GMT+8, 2023-3-24 18:20 , Processed in 0.039294 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表