1.spring--创建项目,选择 CouldDiscovery --->Eureka Discovery + Cloud Config ---->Config Server
2.启动类加入注解:@EnableDiscoveryClient
配置application.yml
3.在github上创建一个项目,本地提交一个application.yml到github的仓库中
4.创建一个文件,起名为order,将application.yml中的内容复制上去
5.在本地的测试项目中,application.yml配置github的访问仓库地址和账号密码
spring: application: name: config cloud: config: server: git: uri: https://github.com/jinqiwen/config-repo username: jinqiwen password: ***********
eureka: client: service-url: defaultZone: http://localhost:8761/eureka/
启动项目,浏览器访问localhost:8080/order-a.yml,如下图,也可是order-b.yml/properties/json等