Spring Cloud Config 是 Spring Cloud 生态中的配置管理组件,支持分布式系统中配置的集中化存储与动态管理。以下是快速启动的关键步骤:
搭建配置服务器
- 使用
spring-cloud-config-server
模块启动服务 - 支持 Git 或本地文件存储配置(如
application.yml
) - 示例命令:
java -jar config-server.jar --spring.profiles.active=dev
- 使用
客户端集成
- 在应用中添加
spring-cloud-starter-config
依赖 - 通过
@EnableConfigServer
注解启用功能 - 配置文件地址格式:
http://localhost:8888/config-name.git[profile]
- 在应用中添加
动态刷新配置
- 使用
Spring Cloud Bus
实现配置更新推送 - 支持消息队列(如 RabbitMQ、Kafka)作为通信载体
- 命令行刷新:
curl -X POST http://localhost:8888/actuator/refresh
- 使用
📌 扩展阅读:Spring Cloud Config 核心概念详解
📦 相关项目:Spring Cloud 官方仓库