私は、アプリケーションのさまざまなプロファイルに基づいて、Springクラウド設定のパターンマッチング機能を実装しようとしています。 http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_environment_repositoryのドキュメントに基づいて、プロファイルに基づいてリポジトリを照合することは可能です。以下は、私が設定クライアントアプリケーション "ユーザー" を持っているとuser.properties、user-development.propertiesを持って、私のconfigサーバapplication.ymlプロファイル用のスプリングクラウド設定パターンの一致
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: ssh://[email protected]/sample/cloud-config-properties.git
repos:
development:
pattern:
-*/development
-*/staging
uri: ssh://[email protected]/development.git
test:
pattern:
-*/test
-*/perf
uri: ${HOME}/Documents/cloud-config-sample-test
ある文書に基づいて
をuser-test.properties - アプリケーション名に関係なく、パターンが*/development i、localhost:8888/user/developmentまたはlocalhost:8888/demo/developmentと一致する場合、my config serverはプロファイルパターンと一致し、適切なプロパティを取得する必要があります。 例:http://localhost:8888/demo/development 私はSSHからdemo-development.propertiesを取得する必要があります://[email protected]/development.git
しかし、私のアプリケーションでは、デフォルトのURIは、すべてのプロファイルに使用されますが、私のプロパティファイルのデモ、すなわち.propertiesは から返されます。uri:ssh://[email protected]/sample/cloud-config-properties.git
これについての指針はありますか?
EDIT:あなたは2つの方法のいずれかを選択できます。ここでのパターンマッチングのソースコードにいくつかのデバッグ後 の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>
あなたはどのバージョンを使用していますか? – spencergibb
Brixton.M5 のpom.xml: \t org.springframework.cloud \t ばねクラウドスタータ親 \t Brixton.M5 \t \t –