Spring Cloud Config

小凯   |     |   框架   |   6分钟   |   107浏览  

https://blog.csdn.net/a561066292/article/details/81357754?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522162056185716780271572826%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=162056185716780271572826&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_v2~rank_v29-2-81357754.pc_search_result_cache&utm_term=springcloudconfig%E5%85%A5%E9%97%A8&spm=1018.2226.3001.4187
    作用:配置管理


          提供服务端和客户端,服务器存储后端的默认实现使用git,因此它轻松支持标签版本的配置环境。Config是静态配置的。

如果需要动态配置,可以使用spring cloud bus进行动态配置更新。

使用:


1.导入依赖



org.springframework.cloud
spring-cloud-config-server



org.springframework.cloud
spring-cloud-starter-netflix-eureka-client

2.配置文件(properties)


server.port=9999


#指定服务的名称
spring.application.name=config-server


#注册到eureka的注册中心
eureka.client.register-with-eureka=true


#获取注册实例的列表
eureka.client.fetch-registry=true


#配置注册中心的地址


#eureka.client.serviceUrl.defaultZone=http://eureka-02.com:4040/eureka
eureka.client.serviceUrl.defaultZone=http://localhost:4040/eureka/


#心跳间隔拉取时间
eureka.instance.lease-renewal-interval-in-seconds=10


#等待心跳超时时间
eureka.instance.lease-expiration-duration-in-seconds=10


#实例id
eureka.instance.instance-id=config-server-9999


#git仓库地址
spring.cloud.config.server.git.uri=https://gitee.com/peng-fengkai/spring-cloud-config-01.git


#git登录帐号
spring.cloud.config.server.git.username=19802871486


#git登录密码
spring.cloud.config.server.git.password=19802871486pfk


#仓库中的相对地址,即文件夹,不可缺省。多个文件夹用逗号隔开,可以使用表示git下所有路径
spring.cloud.config.server.git.searchPaths=


3.开启注解


@EnableConfigServer

如果你觉得文章对你有帮助,那就请作者喝杯咖啡吧☕
微信
支付宝
  条评论