什么是spring cloud:
配置中心,也就是springboot项目中不用写application-dev.yml这些文件了。所有的配置信息都可以从spring cloud中获取。但是application.yml和bootstrap.yml还是得有一个,因为需要一些自己配置的信息。
spring cloud(service端代码)
yml文件:
cloud:
config:
server:
git:
uri: https://gitee.com/chenlingxiang123/project.git
password: xxxxx
username: xxx
search-paths:
default-label: master
label: master
spring cloud (client代码)
cloud:
config:
fail-fast: false #客户端连接失败时开启重试,需要结合spring-retry、spring-aop
label: master #获取配置文件的分支名
name: application #获取的文件名
profile: dev #文件后缀
uri: http://localhost:3344 #配置中心服务端地址
profiles:
active: dev
如果服务器端成功,注意application指的是文件的名称,dev值得是后缀
application-dev
http://localhost:3344/application/dev