Apollo config配置中心 配置列表和map DEMO

Apollo config配置中心 配置列表和map DEMO
#支持可扩展 Apollo配置 apollo中配置如下:

defaultId = 100,200  
chooseId = {"300":"A","400":"B","500":"C"}
callback.url = http://localhost:8080/hello

 

java代码:

@Configuration
@Data
public class TestConfig {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Value("#{'${defaultId:\"100\",\"200\"}'.split(',')}")
    private List<String> defaultId;
    @Value("#{${chooseId:{\"300\":\"A\",\"400\":\"B\",\"500\":\"C\"}}}")
    private Map<String, String> chooseId;

    @Value("${callback.url:abc}")
    private String callbackUrl;

    
    @PostConstruct
    public void init(){
        logger.info("defaultId=[{}]", GsonUtils.toJson(defaultId));
        logger.info("chooseId=[{}]", GsonUtils.toJson(chooseId));
    }
}

 

posted on 2022-04-26 18:57  oktokeep  阅读(1170)  评论(3编辑  收藏  举报