【发布时间】:2016-07-28 23:34:12
【问题描述】:
我正在尝试根据应用程序的不同配置文件来实现 spring 云配置的模式匹配功能。根据http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_environment_repository 中的文档,可以根据配置文件匹配存储库。下面是我的配置服务器 application.yml
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: ssh://xxxx@github/sample/cloud-config-properties.git
repos:
development:
pattern:
-*/development
-*/staging
uri: ssh://git@xxxgithub.com/development.git
test:
pattern:
-*/test
-*/perf
uri: ${HOME}/Documents/cloud-config-sample-test
我有一个配置客户端应用程序“用户”,并且有 user.properties、user-development.properties、user-test.properties
根据文档 - 无论应用程序名称如何,如果模式匹配 */development 即 localhost:8888/user/development 或 localhost:8888/demo/development 我的配置服务器应该匹配配置文件模式并获取适当的属性。 例如:http://localhost:8888/demo/development 我应该从 ssh://git@xxxgithub.com/development.git 获得 demo-development.properties
但在我的应用程序中,默认 uri 用于所有配置文件,即我的属性文件 demo.properties 是从 uri:ssh://xxxx@github/sample/cloud-config-properties.git
这方面有什么建议吗?
编辑: pom.xml
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.M5</version>
<relativePath />
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-monitor</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshots-continuous</id>
<name>Spring Snapshots Continuous</name>
<url>http://repo.spring.io/libs-snapshot-continuous-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/libs-release-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
【问题讨论】:
-
你用的是什么版本?
-
Brixton.M5 pom.xml:
org.springframework.cloud spring-cloud-starter-parent Brixton.M5
标签: spring spring-boot cloud config spring-cloud