方式 | 支持 |
---|---|
@Value("${xxx}") |
支持 |
@ConfigurationProperties(prefix = "xxx") |
不支持 |
- 基于
@RefreshScope
- 基于
EnvironmentChangeEvent
- 需要编写一定的代码
- 需要额外的指出
namespaces
- 引入依赖:
<parent>
<groupId>cn.yzw</groupId>
<artifactId>apollo-auto-refresh-spring-boot-starter</artifactId>
<version>最新版本</version>
</parent>
- 在
main
方法所在的类头顶上加上@EnableApolloAutoRefresh
注解即可 - 关于namespaces的配置:
@EnableApolloConfig
的value
属性可以配置@EnableApolloAutoRefresh
的value
属性也可以配置- 监控的namespace取第一第二点的
value
的并集