简单配置
使用@Value注解的配置会自动刷新配置
复杂对象
代码语言:javascript复制@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");
}
}