【发布时间】:2016-03-15 16:21:58
【问题描述】:
我有以下 Spring cloud config application.yml:
spring:
application:
name: configserver
cloud:
config:
server:
git:
uri: https://xyz@bitbucket.org/xyz/microservices-configs.git
username: xyz
password: xyz
basedir: target/configs
server:
port: 8881
以下是我的用户微服务bootstrap.yml:
spring:
application:
name: userservice
cloud:
config:
uri: http://localhost:8881/
场景 - 1
当我像这样在浏览器中点击配置服务器时:http://localhost:8881/development/userservice-development.yml
它正确地提供文件。当我查看basedir 即目标/配置时,我看到:
- userservice.yml
- gateway.yml
正是我想要的,因为我只在开发分支中添加了这两个文件。
场景 - 2
当我使用以下命令运行我的 userservice 微服务项目时:mvn clean spring-boot:run -Dspring.profiles.active=development
它从 git 获取正确的文件,但 它从 master 分支结帐! 但 不是从开发分支,正如我所期望的那样。我期待对吗? (仅供参考,我在 master 分支中有开发和生产 yml)
所以问题是,我们如何使用配置服务器?是否有任何配置可以设置为仅从该特定分支获取 yml ?我相信我们需要设置一些标签,因为根据文档,默认标签是主标签。谁能告诉我在上述场景中我们如何设置标签?
【问题讨论】:
标签: spring git spring-mvc spring-boot spring-cloud