apollo配置动态更新

简单配置

使用@Value注解的配置会自动刷新配置

复杂对象

@Component("systemConfig")
@ConfigurationProperties(prefix = "cword")
@RefreshScope
@EnableApolloConfig("cword")
public class SystemConfig {
 
    private Resource filePath;
    private Resource tempFilePath;
 
    @Autowired
    private org.springframework.cloud.context.scope.refresh.RefreshScope refreshScope;
    @ApolloConfigChangeListener("cword")
    private void configChange(ConfigChangeEvent changeEvent){
        refreshScope.refresh("systemConfig");
    }
}
发布了221 篇原创文章 · 获赞 9 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/lp19861126/article/details/103131800