![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Spring
EvanDeveloper
Write the Code, Change the World
展开
-
Spring框架中的afterPropertiesSet方法
一、简单介绍1、init-method方法,初始化bean的时候执行,可以针对某个具体的bean进行配置。init-method需要在applicationContext.xml配置文档中bean的定义里头写明。例如:这样,当TestBean在初始化的时候会执行TestBean中定义的init方法。2、afterPropertiesSet方法,初始化bean的时候执行,可以针对某个具体的bean进行配置。afterPropertiesSet 必须实现 InitializingBean接口。实现 Ini原创 2021-03-18 13:52:30 · 10230 阅读 · 0 评论 -
Spring框架中bean的生命周期
本文来探讨一下Spring框架中的Bean的生命周期: 1、实例化 当我们的程序加载beans.xml文件的时候发生,把我们的bean(前提是scope = singleton)实例化到内存中 2、设置属性 调用set方法设置属性 3、如果实现了Bean转载 2021-03-18 13:51:34 · 128 阅读 · 0 评论