Giter Site home page Giter Site logo

spring-cloud-example's Introduction

项目需求

spring cloud config 实现配置管理及动态刷新

spring cloud config + spring cloud bus + spring boot maven + java8
另外需要本地安装 rabbitmq

项目架构

架构图

spring cloud config 简介

用于集中管理项目配置(可以基于不同的版本),当项目启动的时候从config server 上拉取配置
bootstrap.yml 的优先级低于 application.yml
如果配置了spring.cloud.config.allowOverride=true,bootstrap 的属性被会被远程config server中的属性值替换

服务端配置

下面是一个简单的git地址配置,复杂的配置可以通过官网查看,比如实现不同团队项目分离等

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/spring-cloud-samples/config-repo
          username: trolley
          password: strongpassword


客户端配置

客户端通过 name,profile,label 来决定读取服务端的哪一个配置属性

比如 foo-dev.yml

spring:
  application:
    name: foo
  profiles:
    active: dev,mysql

spring cloud bus

spring cloud config 只能在项目启动时拉取配置,spring cloud bus可以通过mq实现动态修改配置,配合Spring cloud config
现在依赖 endpoint 的这个路径 /bus/refresh
回调的配置:http://c3e6388e.ngrok.io/bus/refresh

依赖:rabbitmq (需要自己安装) http://localhost:15672

配置的动态刷新可以通过两种方式,定时从服务器pull,或者监听服务端的push

spring cloud bus,就是通过mq向客户端push消息,触发客户端去更新数据。

触发事件可以通过github的webhook来实现,回调地址可以通过下面的工具代理到localhost

https://ngrok.com/

spring-cloud-example's People

Contributors

tigermoon avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.