简单记一下 @RefreshScope刷新机制

@RefreshScope刷新机制
1. 前置条件
1.1 RefreshAutoConfiguration 作为配置, 然后注入ContextRefresher
1.2 scope 必须是 refresh
2. 项目启动后nacos 发布刷新事件(ContextRefreshedEvent)
3. RefreshScope 监听到该事件后,更新环境变量,并发布环境变动通知
4. ConfigurationPropertiesRebinder 监听到变动之后 调用rebind 对对应的bean对象重新赋值

posted @ 2023-07-06 09:42  ppx-gg  阅读(221)  评论(0)    收藏  举报