springboot启动之afterpropertiesset方法

1、init-method方法,初始化bean的时候执行,可以针对某个具体的bean进行配置。init-method需要在applicationcontext.xml配置文档中bean的定义里头写明。例如:

这样,当testbean在初始化的时候会执行testbean中定义的init方法。

2、afterpropertiesset方法,初始化bean的时候执行,可以针对某个具体的bean进行配置。
afterpropertiesset 必须实现 initializingbean接口。实现 initializingbean接口必须实现afterpropertiesset方法。
posted @ 2022-02-22 22:24  durtime  阅读(2455)  评论(0)    收藏  举报