nacos作为配置中心
2023年10月30日小于 1 分钟
上一级页面:index-la
前言
这节课继续学习nacos作为配置中心
从配置中心中加载多个配置集
把原本的配置文件拆分成多个配置文件,称为多个配置集,例如拆分为 datasource.yaml 、 mybatis.yaml 、 others.yaml
更改默认配置行为
修改配置文件 使用yaml格式
spring.application.name=gulimall-coupon
# 默认配置文件使用 yaml后缀
spring.cloud.nacos.config.file-extension=yaml
新建应用名.yaml的配置文件。配置格式选择yaml

默认配置文件使用dev分组
# 默认配置文件使用dev分组
spring.cloud.nacos.config.group=dev
把application.yaml中的内容迁移到 bootstrap.properties中
注释掉 application.yaml
内容

在 bootstrap.properties
中新增配置
# 配置nacos做发现中心
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
