1.导包
<!-- Nacos 配置中心 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
2.Nacos中添加配置文件
注意:文件名是 配置中心微服务名-dev/pro/test .yaml


3.配置文件

- bootstrap.yml
#服务端口号
server:
port: 6000
spring:
#服务名称
application:
name: cloud-config-client
#Nacos
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848 #Nacos注册中心服务地址
config:
server-addr: 127.0.0.1:8848
file-extension: yaml #指定配置文件格式
#监控的配置
management:
endpoints:
web:
exposure:
include: "*"
- application.yml
spring:
#配置文件选择
profiles:
active: dev
4.GROUP的使用
配置文件进行分来:如 TEST_GROUP,DEV_GROUP,PRO_GROUP

调用

网友评论