1.Java中yml中需要的配置
# Spring spring: application: # 应用名称 name: tl-task profiles: # 环境配置 active: dev cloud: nacos: config: # 配置中心地址 server-addr: # 配置文件格式a file-extension: yml # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} refresh-enabled: true enabled: true group: DEFAULT_GROUP extension-configs[0]: data-id: tl-task-dev.yml group: DEFAULT_GROUP refresh: true
2.使用java实体类接受Nacos中的配置
3.启动类中加对应的nacos的连接的地址值跟端口