当前位置:网站首页>4-4 对象生命周期
4-4 对象生命周期
2022-07-26 22:36:00 【沉睡羊sleepysheep】
说明:本节来讲在ioc容器哪个阶段bean做了什么事情

通过案例来说明

创建订单属性


回到xml进行配置

难道要手动计算出价钱吗?我们要让程序计算在哪儿算呢?

这样做没错但是调用一次就要进行一次运算
增加init方法


利用了init-method是在设置完属性以后再去执行的特点来完成了total属性的计算
为了让程序运行看起来更加清晰,我们将对象创建和设置属性的每一个步骤都打印一些文本



![]()
![]()
运行

在销毁时对资源进行释放,该怎么做呢?
![]()
增加用于销毁ioc容器的方法,该方法并没在applicationContext这个接口中进行定义而是放在了classPathXmlapplicationContext这个具体的实现类中,因此在调用方法的时候由idea自动为我们转换回具体的实现类
销毁容器的过程中会自动调用我们在bean中设置的
方法

资源指的是什么?其实在程序运行过程中这些资源,可以是一个文件,也可以是一个网络的连接,甚至还可以是其他系统的调用,这些都被称为资源,而在destory中我们就要将这些资源释放掉,
运行一下

边栏推荐
- What are the use cases in the Internet of things industry in 2022?
- Pre research of data quality management tools Griffin vs deequ vs great expectations vs quality
- [2016] [paper notes] differential frequency tunable THz technology——
- Chapter 3 cross domain issues
- Six challenges facing enterprise data governance!
- Part II - C language improvement_ 6. Multidimensional array
- 会议OA之我的会议
- 29、 Implementation of xv6 file system (GDB tracks mkfs, buffer cache and log)
- Part II - C language improvement_ 9. Linked list
- Re understand the life world and ourselves
猜你喜欢

Lesson 2 of Silicon Valley classroom - building project environment and developing lecturer management interface

2. Realize the map of navigation bar and battle page

文件上传到服务器

What scenarios are Tencent cloud lightweight application servers suitable for?

Real time voice quality monitoring

力扣141题:环形链表

关于可穿戴式NFT你应该知道的一切!

Push to origin/master was rejected error resolution

【C语言】数组
![[C language] array](/img/b7/fe090984af689e45cf3492ff8d4c61.png)
[C language] array
随机推荐
Push to origin/master was rejected error resolution
力扣141题:环形链表
使用AW9523B芯片驱动16路LED时,LED出现误点亮的问题
会议OA之我的会议
Simple SQL optimization
13_ conditional rendering
第二部分—C语言提高篇_10. 函数指针和回调函数
Part II - C language improvement_ 11. Pretreatment
30、 Modern storage system (management database and distributed storage system)
[interview: concurrency 26: multithreading: two-phase termination mode] volatile version
New features of ES6
np. transpose & np.expand_ dims
第3章 跨域问题
[Luogu] p1395 meeting
The nature and proof of the center of gravity of [mathematics] tree
Bid farewell to wide tables and achieve a new generation of Bi with DQL
Application of workflow engine in vivo marketing automation | engine 03
MySQL syntax uses detailed code version
[Luogu] p2341 popular cattle
Method of setting QQ to blank ID