# 配置中心# 1. 添加依赖12345<dependency> <groupId>com.alibaba.boot</groupId> <artifactId>nacos-config-spring-boot-starter</artifactId> <version>0.2.1</version> </dependency># 2. 启动类注解 @NacosPropertySource12345678910@SpringBootApplication // dataId 对应配置管理-配置列表-dataId@NacosPropertySource(dataId = "nacosDemo", autoRefreshed = true) public class NacosDemoApplication { public static void main(String[] args) { SpringApplication.run(NacosDemoApplication.class, args); } }# 3. 配置 nacos 地址123spring: application: name: nacos-demo# 4. 使用配置123456789101112131415@RestController public class CacheController { @NacosValue(value = "${useLocalCache:false}", autoRefreshed = true) private boolean useLocalCache; private static final String template = "useLocalCache is %s!"; @GetMapping("/cache") public String cache() { // 默认返回false return String.format(template, useLocalCache); } }// 此时返回结果 :useLocalCache is false!增加配置并发布1// 返回结果 :useLocalCache is true!