8.【Spring Cloud Alibaba】配置管理-Nacos

使用Nacos管理配置

架构图

image

配置文件遵循的格式 bootstrap.yml

image

pom.xml
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
bootstrap.yml
spring:
  cloud:
    nacos:
      config:
        server-addr: localhost:8848
        file-extension: yaml
  application:
    name: content-center
  profiles:
    active: dev
content-center-dev.yaml
nacos:
  config: okkkkkkk

配置属性动态刷新与回滚

@RefreshScope

应用的配置共享

image

image

image

引导上下文(applicationContext父上下文)

数据持久化

image

搭建生产可用的nacos集群

搭建生产可用的Nacos集群

配置最佳实践总结

image

posted @ 2020-03-01 18:25  程序猿Knight  阅读(325)  评论(0编辑  收藏  举报