apollo配置動態更新

簡單配置

使用@Value註解的配置會自動刷新配置spring

複雜對象

@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");
    }
}
相關文章
相關標籤/搜索