配置中心本地配置
统一配置中心的作用是统一管理微服务的配置文件,把微服务的配置文件放到Github/码云等远程仓库中,然后搭建统一配置中心服务(Spring Cloud Config Server) 从Github上拉取配置,而微服务从配置红线获取配置文件,从而实现了配置文件的统一管理,但是如果出现网络延迟等等原因可能会导致配置文件拉取失败,微服务启动不成功,对于这种情况Sprin Cloud Config提供了配置文件本地化,当Github上的配置文件拉取失败可以从本地加载配置文件。
一.方式一
ps:基于 Spring Cloud Config Server 配置中心服务进行修改 ,直接指定Git远程仓库对应的本地仓库位置
eureka:
client:
serviceUrl:
defaultZone: http://localhost:1010/eureka/ #注册中心地址
instance:
prefer-ip-address: true #使用ip地址注册
instance-id: hrm-config-server #指定服务的id
server:
port: 1030
spring:
application:
name: hrm-config-server
cloud:
config:
server:
git:
uri: https://gitee.com/baidu11.com/hrm-config.git1 #配置远程仓库地址
username: 1456868501@qq.com
password: wodemima123
repos: #仓库配置
local: #git对应的本地仓库配置
pattern: application* #匹配所有以application开头的配置文件