2config 本地模式 · SpringCloud微服务实战 · 看云

2. 配置信息-本地模式

导航

本节代码地址


2.1searchLocations的配置描述

  • 绝对路径 如 file:D:/workspace/fw-repo
  • 相对路径:如classpath:/native
  • 默认路径:classpath:/
    在application.yml 中设置本地的配置
spring:
  application:
    name: fw-config-server
  profiles:
    active: native
  cloud:
    config:
      server:
        native:
          searchLocations: classpath:/native 
eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka

2.2 添加配置文件

比如我们使用的是相对路径:如classpath:/native,将配置复制过来
e5e1bb0ea34d346fb491a564ea53e07f_MD5.webp

不管服务端使用什么模式,对客户端均不受影响

2.3 启动项目

浏览器或Postman 输入地址localhost:8778/fw-register-eureka-client.yml(其它几个类同)
b8c5230b57225126e3bbbdef7ed43efe_MD5.webp