apollo configuring dynamic update

Simple Configuration

Use @Value annotations configured automatically refresh configuration

Complex object

@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");
    }
}
Published 221 original articles · won praise 9 · views 130 000 +

Guess you like

Origin blog.csdn.net/lp19861126/article/details/103131800