手册

eureka替换为nacos

664
黎彩霞
2021-05-14 18:01:15
分享链接

1. 搭建nacos-server

https://nacos.io/zh-cn/index.html

请参考官网访问搭建

2修改base模块的pom.xml

eureka依赖注释

nacos依赖的注释去掉


3. 修改5个微服务的配置

这里以uc微服务举例说明

3.1 添加文件bootstrap.yml文件

3.2 配置nacos-server

Nacos-Server中新建配置,其中Data ID它的定义规则是:${prefix}-${spring.profile.active}.${file-extension}

  • prefix 默认为 spring.application.name 的值,也可以通过配置项 spring.cloud.nacos.config.prefix 来配置。
  • spring.profile.active 即为当前环境对应的 profile,可以通过配置项 spring.profile.active 来配置。
  • file-exetension 为配置内容的数据格式,可以通过配置项 spring.cloud.nacos.config.file-extension 来配置。目前只支持 properties  yaml 类型。

注意:当 spring.profile.active 为空时,对应的连接符 - 也将不存在, dataId 的拼接格式变成 ${prefix}.${file-extension}


eip-uc-dev.yml



发表评论
评论通过审核后显示。