当前位置: 首页 > article >正文

Spring Cloud Config 2.2.2 是 Spring Cloud 的一个**配置中心组件版本**

Spring Cloud Config 2.2.2 是 Spring Cloud 的一个配置中心组件版本发布于 2020 年 3 月属于 Spring Cloud Hoxton.SR3 版本栈基于 Spring Boot 2.2.x 构建。该版本已停止官方维护EOLSpring 官方自 2021 年起已将 Config Server 的演进重心转向Spring Cloud Config 3.x Spring Boot 2.4支持 Config Data API并最终在 Spring Cloud 2022.xKilburn及之后完全弃用旧版spring-cloud-config-server的传统加载机制。主要特性针对 2.2.2支持 Git、SVN、本地文件系统等后端存储配置提供/actuator/env、/actuator/configprops等监控端点需启用 Actuator客户端通过spring.cloud.config.uri拉取配置支持 profile、label如分支名动态匹配支持对称/非对称加密JCE 或 Vault 集成与 Eureka、BusRabbitMQ/Kafka 实现配置刷新可集成但 Bus 在后续版本中也被标记为维护模式。⚠️ 注意事项不兼容 Spring Boot 2.4 的新配置加载机制ConfigDataLocationResolver存在已知安全漏洞如 CVE-2020-5412路径遍历风险不建议用于新项目官方文档归档地址https://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.2.2.RELEASE/推荐升级路径→ Spring Cloud 2021.0.xJubilee Spring Boot 2.6.x过渡→ Spring Cloud 2022.0.xKilburn Spring Boot 3.0Java 17使用spring-config-data新模型# 示例Config Client2.2.2bootstrap.yml注意Boot 2.4 已废弃 bootstrapspring:application:name:demo-servicecloud:config:uri:http://config-server:8888profile:devlabel:mainSpring Cloud Config 2.2.2Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments. The concepts on both client and server map identically to the Spring Environment and PropertySource abstractions, so they fit very well with Spring applications, but can be used with any application running in any language. As an application moves through the deployment pipeline from dev to test and into production you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate. The default implementation of the server storage backend uses git so it easily supports labelled versions of configuration environments, as well as being accessible to a wide range of tooling for managing the content. It is easy to add alternative implementations and plug them in with Spring configuration.FeaturesSpring Cloud Config Server features:HTTP, resource-based API for external configuration (name-value pairs, or equivalent YAML content) Encrypt and decrypt property values (symmetric or asymmetric) Embeddable easily in a Spring Boot application using EnableConfigServerConfig Client features (for Spring applications):Bind to the Config Server and initialize Spring Environment with remote property sources Encrypt and decrypt property values (symmetric or asymmetric)Getting StartedAs long as Spring Boot Actuator and Spring Config Client are on the classpath any Spring Boot application will try to contact a config server on http://localhost:8888, the default value of spring.cloud.config.uri. If you would like to change this default, you can set spring.cloud.config.uri in bootstrap.[yml | properties] or via system properties or environment variables.ConfigurationEnableAutoConfigurationRestControllerpublic class Application {Value(“${config.name}”)String name “World”;RequestMapping(“/”)public String home() {return Hello name;}public static void main(String[] args) {SpringApplication.run(Application.class, args);}}The value of config.name in the sample (or any other values you bind to in the normal Spring Boot way) can come from local configuration or from the remote Config Server. The Config Server will take precedence by default. To see this look at the /env endpoint in the application and see the configServer property sources.To run your own server use the spring-cloud-config-server dependency and EnableConfigServer. If you set spring.config.nameconfigserver the app will run on port 8888 and serve data from a sample repository. You need a spring.cloud.config.server.git.uri to locate the configuration data for your own needs (by default it is the location of a git repository, and can be a local file:… URL).在 Spring Cloud Config 2.2.2对应 Spring Cloud Hoxton.SR3中与Spring Cloud Bus通常基于 RabbitMQ 或 Kafka配合实现配置的自动刷新即“配置变更→广播→客户端热更新”需分服务端Config Server Bus和客户端Config Client Bus协同完成。该机制本质是Config Server 接收/actuator/bus-refresh请求 → 通过 Bus 广播 RefreshRemoteApplicationEvent → 所有订阅 Bus 的客户端监听并触发RefreshScopeBean 重载。✅ 前提条件Spring Boot 2.2.x如 2.2.6.RELEASESpring Cloud Hoxton.SR3含 Config 2.2.2、Bus 2.2.1消息中间件RabbitMQ推荐或 Kafka需对应版本兼容 一、服务端Config Server配置1. 添加依赖MavendependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-config-server/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-bus-amqp/artifactId!-- RabbitMQ --/dependency!-- 若用 Kafka替换为 spring-cloud-starter-bus-kafka --2. application.yml 配置spring:application:name:config-serverrabbitmq:host:localhostport:5672username:guestpassword:guestcloud:bus:trace:enabled:true# 可选开启事件追踪便于调试config:server:git:uri:https://github.com/your/config-repodefault-label:mainmanagement:endpoints:web:exposure:include:bus-refresh,health,info,env# 必须暴露 bus-refresh 端点endpoint:bus-refresh:security:sensitive:false# Spring Boot 2.2 默认关闭敏感检查但建议显式设 false✅ 关键/actuator/bus-refresh是 Bus 提供的全局刷新端点POST 请求调用后会广播刷新事件。 二、客户端Config Client配置1. 添加依赖dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-config/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-bus-amqp/artifactId/dependency!-- 注意无需 spring-cloud-config-clientstarter 已包含 --2. bootstrap.yml⚠️ Spring Boot 2.4 已废弃但 2.2.x 必须使用spring:application:name:demo-servicecloud:config:uri:http://localhost:8888profile:devlabel:mainrabbitmq:host:localhostport:5672username:guestpassword:guest3. 启用 RefreshScope 并注入配置RestControllerRefreshScope// ← 关键使 Bean 支持运行时刷新publicclassTestController{Value(${my.property:default-value})privateStringmyProperty;GetMapping(/prop)publicStringgetProp(){returnmyProperty;}}✅RefreshScope作用于类如RestController,Service其代理会在收到 RefreshEvent 后重建 Bean 实例从而读取新配置。 三、触发自动刷新流程修改 Git 仓库中demo-service-dev.yml的my.property: old→my.property: newgit push提交变更手动触发刷新Config Server 端curl-XPOST http://localhost:8888/actuator/bus-refresh# 或按服务粒度刷新推荐生产环境curl-XPOSThttp://localhost:8888/actuator/bus-refresh?destinationdemo-service:**Config Server 通过 Bus 发送RefreshRemoteApplicationEvent所有监听 Bus 的demo-service实例收到事件 → 清空RefreshScope缓存 → 下次请求时重建 Bean → 加载新配置✅ 验证访问/prop返回new⚠️ 注意事项2.2.2 特定spring-cloud-bus在 Hoxton 中已进入维护模式官方不再新增功能不支持spring-boot-starter-actuator2.4 的新 Actuator 结构如exposure.include写法在 2.2.x 有效若使用 Kafka需确保spring-cloud-starter-bus-kafka与 Kafka Broker 版本兼容如 2.2.1 对应 Kafka 2.3.x安全建议为/actuator/bus-refresh添加 Spring Security 认证Basic 或 OAuth2避免未授权调用。// 补充自定义 Bus 刷新监听可选调试ComponentpublicclassBusRefreshListener{EventListenerpublicvoidhandleRefresh(RefreshRemoteApplicationEventevent){System.out.println(Received refresh event for: event.getDestinationService());}}

相关文章:

Spring Cloud Config 2.2.2 是 Spring Cloud 的一个**配置中心组件版本**

Spring Cloud Config 2.2.2 是 Spring Cloud 的一个配置中心组件版本,发布于 2020 年 3 月(属于 Spring Cloud Hoxton.SR3 版本栈),基于 Spring Boot 2.2.x 构建。该版本已停止官方维护(EOL),Sp…...

Spring Cloud App Broker 1.0.5 是 Spring Cloud 团队发布的用于构建云原生服务代理(Service Broker)的开源框架的一个维护版本

Spring Cloud App Broker 1.0.5 是 Spring Cloud 团队发布的用于构建云原生服务代理(Service Broker)的开源框架的一个维护版本。该版本主要包含错误修复、安全补丁、依赖升级(如 Spring Boot、Spring Cloud 及相关组件的兼容性更新&#xff…...

java毕业设计——基于JSP+sqlserver的网上书店系统设计与实现(毕业论文+程序源码)——网上书店

基于JSPsqlserver的网上书店系统设计与实现(毕业论文程序源码) 大家好,今天给大家介绍基于JSPsqlserver的网上书店系统设计与实现,文章末尾附有本毕业设计的论文和源码下载地址哦。需要下载开题报告PPT模板及论文答辩PPT模板等的…...

java毕业设计——基于JSP+sqlserver的网上购物系统设计与实现(毕业论文+程序源码)——网上购物系统

基于JSPsqlserver的网上购物系统设计与实现(毕业论文程序源码) 大家好,今天给大家介绍基于JSPsqlserver的网上购物系统设计与实现,文章末尾附有本毕业设计的论文和源码下载地址哦。需要下载开题报告PPT模板及论文答辩PPT模板等的…...

java毕业设计——基于JSP+sqlserver的网络远程作业处理系统设计与实现(毕业论文+程序源码)——网络远程作业处理系统

基于JSPsqlserver的网络远程作业处理系统设计与实现(毕业论文程序源码) 大家好,今天给大家介绍基于JSPsqlserver的网络远程作业处理系统设计与实现,文章末尾附有本毕业设计的论文和源码下载地址哦。需要下载开题报告PPT模板及论文…...

斜率计算2

斜率计算2 描述 现在给出两个点的坐标,要你求出斜率,这个斜率需要用最简分数表示,同时斜率不存在输出-1 输入 输入4个整数 x1,y1,x2,y2.分别是A,B两点的坐标。 输出 输出两点所确定直线的斜率,不存在则输出-1. 输入样例 1 2…...

C++做石头剪刀布

运作原理程序里1代表石头&#xff1b;2代表布&#xff1b;3代表剪刀&#xff0c;然后让计算机随机从1~3抽一个数&#xff0c;再来判断。界面std::cout << " 石头剪刀布 \n";std::cout << " Rock Paper Scissors \n";std::cout << …...

PCL 计算两点云之间的最小距离【2026最新版】

目录 一、 算法原理 二、 代码实现 三、 结果展示 四、 相关链接 本文由CSDN点云侠原创,原文链接,首发于:2023年11月24日。博客长期更新,本文最新更新时间为:2026年3月15日。 一、 算法原理 pcl::registration::CorrespondenceEstimation是确定目标和查询点集(或特征)之…...

NPU算力突破对其他行业的意义是什么?

NPU&#xff08;神经网络处理器&#xff09;算力突破100 TOPS&#xff08;每秒万亿次运算&#xff09;&#xff0c;不仅是手机行业的里程碑&#xff0c;更是汽车、医疗、工业和物联网等多个领域智能化转型的关键催化剂。这一算力阈值的跨越&#xff0c;意味着复杂的AI大模型可以…...

CRMEB 陀螺匠合同签约功能说明

合同签约一、功能简介合同签约支持使用线上腾讯电子签&#xff0c;也支持线下签约后&#xff0c;将签约文件录入系统进行记录。二、操作说明1. 页面路径&#xff1a;客户 > 合同签约2. 电子签流程&#xff1a;一号通合同状态&#xff1a;INIT合同创建&#xff0c;PART合同签…...

阿里云的各种产品都是干什么的?

ECS (Elastic Compute Service)&#xff1a;以虚拟机的方式将一台物理机分成多台云服务器&#xff0c;提供可伸缩的计算服务。 SLB (Server Load Balance&#xff09;&#xff1a;基于LVS和Tengine实现的4层和7层负载均衡&#xff0c;有动态扩容&#xff0c;session保持等特点…...

Spring Boot 外部化配置优先级

1、优先级排序开发者通过编程方式提供的配置&#xff1a;使用 SpringApplicationBuilder 或者 SpringApplication 直接设置的属性。命令行参数&#xff1a;运行时传递给应用程序的命令行参数&#xff0c;如 java -jar app.jar --server.port8081。Java系统属性&#xff08;Syst…...

文本分析(停用词库)

集合百度停用词表、中文停用词表、哈工大停用词库、四川大学机器智能实验室停用词库。在原文基础上加入了自己实验的停用词。分析 建设 结构 三只 松鼠 三只松鼠 我国 干部 关系 解决 提出 领域 始终 特别 做出 作出 提供 十八 党内 这是 更好 第一 第二 第三 第四 第五 第六 着…...

ThreadLocal为什么能实现线程数据隔离

ThreadLocal的get()和set()方法会访问当前线程的ThreadLocalMap&#xff0c;每个线程都有自己独立的ThreadLocalMap实例。这个映射表以ThreadLocal实例this作为键&#xff0c;与线程特定的值&#xff08;value&#xff09;相关联&#xff0c;因此每个线程既使通过同一个ThreadL…...

Social-Engineer Toolkit (SET) 终极指南:10大社会工程攻击向量深度解析

Social-Engineer Toolkit (SET) 终极指南&#xff1a;10大社会工程攻击向量深度解析 【免费下载链接】social-engineer-toolkit The Social-Engineer Toolkit (SET) repository from TrustedSec - All new versions of SET will be deployed here. 项目地址: https://gitcode…...

Siri Ultra开发路线图:未来将新增哪些令人期待的LLM功能?

Siri Ultra开发路线图&#xff1a;未来将新增哪些令人期待的LLM功能&#xff1f; 【免费下载链接】siri-ultra The most intelligent Siri powered by LLMs 项目地址: https://gitcode.com/gh_mirrors/si/siri-ultra Siri Ultra作为一款由LLMs&#xff08;大型语言模型&…...

如何快速集成 Vue Google Autocomplete:打造智能地址搜索体验

如何快速集成 Vue Google Autocomplete&#xff1a;打造智能地址搜索体验 【免费下载链接】vue-google-autocomplete A Vue.js autosuggest component for the Google Places API. 项目地址: https://gitcode.com/gh_mirrors/vu/vue-google-autocomplete Vue Google Aut…...

Takahē社区建设指南:服务器公告、用户互动与内容 moderation 策略

Takahē社区建设指南&#xff1a;服务器公告、用户互动与内容 moderation 策略 【免费下载链接】takahe An ActivityPub/Fediverse server 项目地址: https://gitcode.com/gh_mirrors/ta/takahe Takahē 作为一款强大的 ActivityPub/Fediverse 服务器&#xff0c;为社区…...

Buster批量电子邮件处理教程:从列表导入到结果分析

Buster批量电子邮件处理教程&#xff1a;从列表导入到结果分析 【免费下载链接】buster An advanced tool for email reconnaissance 项目地址: https://gitcode.com/gh_mirrors/bus/buster Buster是一款强大的电子邮件侦察工具&#xff0c;能够帮助用户高效处理批量电子…...

探索全栈新境界:Angular Full Stack项目解读

探索全栈新境界&#xff1a;Angular Full Stack项目解读 【免费下载链接】Angular-Full-Stack DavideViolante/Angular-Full-Stack: 是一个用于 Angular 的企业级全栈应用模板。适合对 Angular 和全栈开发有兴趣的人&#xff0c;特别是想快速构建基于 Angular 的企业级应用的人…...

10分钟上手Library:新闻团队协作文档系统快速搭建指南

10分钟上手Library&#xff1a;新闻团队协作文档系统快速搭建指南 【免费下载链接】library A collaborative documentation site, powered by Google Docs. 项目地址: https://gitcode.com/gh_mirrors/libr/library Library是一款基于Google Docs的协作新闻编辑室文档系…...

如何利用Touca实现工程团队的持续回归测试:完整指南

如何利用Touca实现工程团队的持续回归测试&#xff1a;完整指南 【免费下载链接】trytouca Continuous Regression Testing for Engineering Teams 项目地址: https://gitcode.com/gh_mirrors/tr/trytouca Touca是一款专为工程团队打造的持续回归测试工具&#xff0c;它…...

java毕业设计下载(全套源码+配套论文)——基于javaEE+SSH+mysql的医院在线挂号系统设计与实现

基于javaEESSHmysql的医院在线挂号系统设计与实现&#xff08;毕业论文程序源码&#xff09; 大家好&#xff0c;今天给大家介绍基于javaEESSHmysql的医院在线挂号系统设计与实现&#xff0c;更多精选毕业设计项目实例见文末哦。 文章目录&#xff1a; 基于javaEESSHmysql的医…...

java毕业设计下载(全套源码+配套论文)——基于javaEE+SSH+mysql的百货中心供应链管理系统设计与实现

基于javaEESSHmysql的百货中心供应链管理系统设计与实现&#xff08;全套源码配套论文&#xff09; 大家好&#xff0c;今天给大家介绍基于javaEESSHmysql的百货中心供应链管理系统设计与实现&#xff0c;更多精选毕业设计项目实例见文末哦。 文章目录&#xff1a; 基于javaE…...

java毕业设计,基于java+原生Sevlet+socket的聊天室系统设计与实现(全套源码+配套论文),聊天室系统

基于java原生Sevletsocket的聊天室系统设计与实现&#xff08;全套源码配套论文&#xff09; 大家好&#xff0c;今天给大家介绍基于java原生Sevletsocket的聊天室系统设计与实现&#xff0c;更多精选毕业设计项目实例见文末哦。 文章目录&#xff1a; 基于java原生Sevletsoc…...

java毕业设计,基于java+swing+GUI的雷电游戏GUI设计与实现(全套源码+配套论文),雷电游戏

基于javaswingGUI的雷电游戏GUI设计与实现&#xff08;全套源码配套论文&#xff09; 大家好&#xff0c;今天给大家介绍基于javaswingGUI的雷电游戏GUI设计与实现&#xff0c;更多精选毕业设计项目实例见文末哦。 文章目录&#xff1a; 基于javaswingGUI的雷电游戏GUI设计与…...

如何在Mac上安装与使用Emacs Mac Port:完整指南

如何在Mac上安装与使用Emacs Mac Port&#xff1a;完整指南 【免费下载链接】homebrew-emacsmacport Emacs mac port formulae for the Homebrew package manager 项目地址: https://gitcode.com/gh_mirrors/ho/homebrew-emacsmacport Emacs Mac Port是为macOS系统优化的…...

如何快速使用Tiled2Unity:从Tiled地图到Unity的完整导出指南

如何快速使用Tiled2Unity&#xff1a;从Tiled地图到Unity的完整导出指南 【免费下载链接】Tiled2Unity Export Tiled Map Editor (TMX) files into Unity 项目地址: https://gitcode.com/gh_mirrors/ti/Tiled2Unity Tiled2Unity是一款强大的工具&#xff0c;能够将Tiled…...

Hasura Backend Plus核心功能解析:JWT认证与S3存储无缝集成

Hasura Backend Plus核心功能解析&#xff1a;JWT认证与S3存储无缝集成 【免费下载链接】hasura-backend-plus &#x1f511;Auth and &#x1f4e6;Storage for Hasura. The quickest way to get Auth and Storage working for your next app based on Hasura. 项目地址: ht…...

java毕业设计下载(全套源码+配套论文)——基于java+Servlet+SqlServer的医院管理住院系统设计与实现

基于javaServletSqlServer的医院管理住院系统设计与实现&#xff08;毕业论文程序源码&#xff09; 大家好&#xff0c;今天给大家介绍基于javaEE原生ServletSqlServer的医院管理住院系统设计与实现&#xff0c;更多精选毕业设计项目实例见文末哦。 文章目录&#xff1a; 基…...