Spring Cloud Config-快速开始

启动服务器:java

$ cd spring-cloud-config-server  
$ ../mvnw spring-boot:run

 该服务器是一个Spring Boot应用程序,因此您能够从IDE运行它,而不是喜欢(主类是ConfigServerApplication)。而后尝试一个客户端:git

$ curl localhost:8888/foo/development  
{"name":"development","label":"master","propertySources":[  
  {"name":"https://github.com/scratches/config-repo/foo-development.properties","source":{"bar":"spam"}},  
  {"name":"https://github.com/scratches/config-repo/foo.properties","source":{"foo":"bar"}}  
]}

定位资源的默认策略是克隆一个git仓库(在spring.cloud.config.server.git.uri),并使用它来初始化一个迷你SpringApplication。小应用程序的Environment用于枚举属性源并经过JSON端点发布。github

HTTP服务具备如下格式的资源:spring

/{application}/{profile}[/{label}]  
/{application}-{profile}.yml  
/{label}/{application}-{profile}.yml  
/{application}-{profile}.properties  
/{label}/{application}-{profile}.properties

 

其中“应用程序”做为SpringApplication中的spring.config.name注入(即常规的Spring Boot应用程序中一般是“应用程序”),“配置文件”是活动配置文件(或逗号分隔列表的属性),“label”是可选的git标签(默认为“master”)。服务器

Spring Cloud Config服务器从git存储库(必须提供)为远程客户端提供配置app

spring:  
  cloud:  
    config:  
      server:  
        git:  
          uri: https://github.com/spring-cloud-samples/config-repo

完整项目的源码来源 技术支持求求1791743380curl

相关文章
相关标签/搜索