SpringCloud------客户端服务适配配置中心

1.前提

配置中心已经完成配置

参考

https://www.cnblogs.com/tianhengblogs/p/12507862.html

 

2.添加依赖

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

 

3.修改application.yml为bootstrap.yml

 

4.修改bootstrap.yml

除了以下配置,其它配置放到git服务器配置

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

spring:
  application:
    name: product-service
  cloud:
    config:
      discovery:
        enabled: true
        #指定从哪个配置中心读取配置
        service-id: config-server
      #文件名称(前缀)
      name: product-service
      #文件名称(后缀,可添加多个)环境dev,test
      profile: test
      #分支master(默认),test
      label: test

 

posted @ 2020-03-17 00:10  玉天恒  阅读(358)  评论(0编辑  收藏  举报