{"id":19885227,"url":"https://github.com/dinstone/msa-spring-cloud","last_synced_at":"2026-01-06T21:05:49.335Z","repository":{"id":68551332,"uuid":"125359597","full_name":"dinstone/msa-spring-cloud","owner":"dinstone","description":"spring cloud best practice","archived":false,"fork":false,"pushed_at":"2024-05-24T05:32:58.000Z","size":176,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T04:03:52.688Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dinstone.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-15T11:49:44.000Z","updated_at":"2024-05-24T05:33:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"61df248b-4784-4f7b-8f57-e47df1f78309","html_url":"https://github.com/dinstone/msa-spring-cloud","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinstone%2Fmsa-spring-cloud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinstone%2Fmsa-spring-cloud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinstone%2Fmsa-spring-cloud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dinstone%2Fmsa-spring-cloud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dinstone","download_url":"https://codeload.github.com/dinstone/msa-spring-cloud/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245580989,"owners_count":20638906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T17:33:39.786Z","updated_at":"2026-01-06T21:05:49.304Z","avatar_url":"https://github.com/dinstone.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 架构选型 FQA\n\n### 1 : config动态配置有哪几种方式？\n\n主要有三种方式配置可以动态刷新：（高版本的需要引入依赖：spring-cloud-starter-bootstrap）\n\n   1. Environment获取配置，可以动态更新；\n   2. @Value 需要配合@RefreshScope 才能获取到动态配置；\n   3. @ConfigurationProperties 可以获取到动态配置。\n\n### 2 : 配置项中的所有字段都会自动应用吗？\n\n不是的。只有使用了上面的三种方式获取配置的组件才能享受配置的自动更新特性。比如server.port的变动是不会起作用的。\n\n### 3 : 怎么实现配置刷新？\n\n需要调用ContextRefresher.refresh()方法。\n\n   1. 手动刷新，当配置文件变更后，手动调用配置客户端的接口，接口中发送ApplicationContext.publishEvent(RefreshEvent)事件，或者使用/actuator/refresh端点触发ContextRefresher.refresh()方法调用。\n   2. 自动刷新，当发现配置文件变更后，自动发送ApplicationContext.publishEvent(RefreshEvent)事件。或者使用 spring cloud bus消费配置变更消息来触发更新。\n\n#### 4 : Gateway可以动态变更路由信息吗？\n\n可以通过动态配置刷新路由列表，实时生效，不会对访问造成影响。\n\n### 5 : Spring cloud 核心组件选型？\n\n核心组件选型：\n   1. 服务网关: Spring Cloud Gateway\n   2. 服务管理: Consul\n   3. 配置管理: Consul\n   4. 服务调用: RestTemplate、OpenFeign、Spring Cloud Loadbalancer\n   5. 流量治理: Spring Cloud Circuit Breaker\n   6. 可观测性: Spring Cloud Sleuth、Spring Actuator、Prometheus\n\n### 6 : 如何实现开发、测试环境的多分支协作， 以及生产环境的灰度发布？\n\n1. 每个服务定义3组元数据标签：环境（Environment）、泳道（Swimlane）、版本（version）\n* Environment：develop、testing、product\n* Swimlane：stable、gray; feature\n* Version：xx.yy.zz 由主版本号、次版本号和修订号三部分组成，例如：1.20.13\n\n2. 定义泳道路由组件，增强服务路由能力，支持多分支协助的开发、测试和生产环境的灰度发布。\n\n\n## 快速开始 FQA\n\nQ: 如何构建spring cloud基础设施？\n\nA: docker 环境构建是最快，最省力的方式。\n\n1. [prometheus \u0026 pushgateway](https://blog.csdn.net/qq_36120342/article/details/119758402)\n\nprometheus.yml\n\n```\n# my global config\nglobal:\n  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.\n  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.\n  # scrape_timeout is set to the global default (10s).\n\n# Alertmanager configuration\n\n# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.\nrule_files:\n  # - \"rules/alert_rules.yml\"\n  # - \"first_rules.yml\"\n  # - \"second_rules.yml\"\n\n# A scrape configuration containing exactly one endpoint to scrape:\n# Here it's Prometheus itself.\nscrape_configs:\n  # The job name is added as a label `job=\u003cjob_name\u003e` to any timeseries scraped from this config.\n  - job_name: prometheus\n    static_configs:\n    - targets: ['192.168.1.120:9090']\n  - job_name: pushgateway\n    static_configs:\n      - targets: ['192.168.1.120:9091']\n        labels:\n          instance: pushgateway\n```\n\n```\ndocker run -d -p 9091:9091 \\\n -v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime\\\n -v $HOME/prometheus/data:/prometheus-data \\\n --name pushgateway prom/pushgateway:latest\n\n docker run -d -p 9090:9090 \\\n -v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime\\\n -v $HOME/prometheus/config:/etc/prometheus \\\n --name prometheus prom/prometheus:latest '--config.file=/etc/prometheus/prometheus.yml'\n```\n\n2. consul\n\n```\ndocker run -d --restart=unless-stopped --name consul -p 8500:8500 -v $HOME/consul:/consul/data consul agent -server -bootstrap -ui -client='0.0.0.0'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinstone%2Fmsa-spring-cloud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdinstone%2Fmsa-spring-cloud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdinstone%2Fmsa-spring-cloud/lists"}