NacosContextRefresher配置刷新及@refreshScope

681 阅读1分钟

配置文件的动态更新

  • 通常获取配置文件的方式包含两种

    • @Value
    • @ConfigurationProperties(Prefix)
  • 如果是在运行时要动态更新的话,配合nacos使用时,配置更新时会自动调用nacosNacosContextRefresher,此时

    • 第一种方式要在bean上加@RefreshScope
    • 第二种方式是自动支持的。