zoukankan      html  css  js  c++  java
  • 91--spring cloud (Config配置中心--客户端)

    Config客户端配置

    pom.xml 添加 config 客户端依赖

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

    项目中添加 bootstrap.yml

    bootstrap.yml,引导配置文件,先于 application.yml 加载

    yml的文件名称必须是bootstrap ,不可以是其他的

    具体步骤:

    1. eureka连接地址
    2. 从eureka发现配置中心
    3. 连接配置中心
    4. 下载自己的配置

    配置服务中的bootstrap.yml

    • item-service
    # 连 eureka
    eureka:
      client:
        service-url:
          defaultZone: http://eureka1:2001/eureka,http://eureka2:2002/eureka
    # 发现配置中心(指定配置文件的serviceid)
    spring:
      cloud:
        config:
          discovery:
            enabled: true
            service-id: config-server
          name: item-service
          profile: dev
    
    
    • user-service**
    # 连 eureka
    eureka:
      client:
        service-url:
          defaultZone: http://eureka1:2001/eureka,http://eureka2:2002/eureka
    # 发现配置中心(指定配置文件的serviceid)
    spring:
      cloud:
        config:
          discovery:
            enabled: true
            service-id: config-server
          name: user-service
          profile: dev
    
    
    • order-service
    # 连 eureka
    eureka:
      client:
        service-url:
          defaultZone: http://eureka1:2001/eureka,http://eureka2:2002/eureka
    # 发现配置中心(指定配置文件的serviceid)
    spring:
      cloud:
        config:
          discovery:
            enabled: true
            service-id: config-server
          name: order-service
          profile: dev
    
    
    • zuul
    # 连 eureka
    eureka:
      client:
        service-url:
          defaultZone: http://eureka1:2001/eureka,http://eureka2:2002/eureka
    # 发现配置中心(指定配置文件的serviceid)
    spring:
      cloud:
        config:
          discovery:
            enabled: true
            service-id: config-server
          name: zuul
          profile: dev
    
    

    启动服务,观察从配置中心获取配置信息的日志

    启动服务的顺序

    第一步: 启动注册中心

    第二步: 启动配置中心

    第三步:启动服务项

    注意:必须要按照顺序启动

    在服务启动过程中出现如下,则表示正常 连接端口号为6001

    image-20200904095820025

  • 相关阅读:
    获取CheckBox的Text值
    动态绑定数据至Html Table
    二次事件并细化功能
    ASP.NET MVC的JavaScriptResult
    Google Earth 8.0
    ASP.NET MVC的ContentResult
    ASP.NET MVC使用input标签上传文件
    处理动态SQL语句的参数
    Infor SyteLine如何快速锁定用户
    执行git push出现"Everything up-to-date"
  • 原文地址:https://www.cnblogs.com/liqbk/p/13612531.html
Copyright © 2011-2022 走看看