spring-Cloud-Alibaba-nacos-Config
1.电商微服务架构
2.用户下单场景微服务搭建
3.nacos简单介绍
4. 一般架构设计
5. nacos使用场景
6.springboot和nacos的配置中心整合:
(1)pom.xml
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <version>2.2.5.RELEASE</version> </dependency>
(2)bootstrap.yaml
spring: application: name: configdemo cloud: nacos: config: server-addr: localhost:8848 file-extension: yaml profiles: active: prod #表示我需要向配置中心索要的生产环境的配置
(3)TestController
@RestController @RefreshScope public class TestController { @Value("${testStr}") private String testStr; @GetMapping("/test") public String test(){ return testStr; } }
@RefreshScope:是实时监控配置变化实现动态变更配置
提示 springboot配置文件的优先级(bootstrap.properties>bootstrap.yaml>application.properties>application.yaml)
(4)
(5)通用配置
(6)跨服务共享配置文件
跨服务器
(7)nacos Config动态刷新机制