1.config client端 (要用配置信息的项目)
2.pom依赖

<!--  config客户端-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-client</artifactId>
        </dependency>

3.把yml改成bootstrap.xml

spring:
  application:
    name: product
  cloud:
    config:
      discovery:
        enabled: true 
        service-id: CONFIG  //config的服务名 
      label: master  //分支
      profile: test  环境
#eureka的配置不能写到git上 必须写到外面 不然报错
eureka:
  client:
    service-url:
      defaultZone: http://localhost:8085/eureka/

3.只需要改环境就能随意切换配置

4.config 高可用 起多个实例
springcloud统一配置中心(config client端)
5.客户端会轮询选择可用的config服务

  • 但是还是没有达到自动更新的目的 下一篇继续。

相关文章: