1、创建命名空间
2、在相应的命名空间下创建配置
3、配置
4、在项目中指定namespace
spring:
profiles:
# active: info
# active: test
active: dev
指定namespace的id
server:
port: 3377
spring:
application:
name: nacos-config-client
cloud:
nacos:
discovery:
server-addr: localhost:8848 # nacos服务注册中心
config:
server-addr: localhost:8848
file-extension: yaml # 指定yaml为配置文件后缀
namespace: 8980fb94-9437-47a6-ae30-63b9c8971d8f
# group: DEV_GROUP
# ${prefix}-${spring-profile.active}.${file-extension}
# 约定配置文件名
# ${spring.application.name}-${spring.profile.active}.${spring.cloud.nacos.config.file-extension}
# nacos-config-client-dev.yaml