我有以下的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
即target/config时,我可以看到:- userservice.yml
- gateway.yml
这正是我想要的,因为我只在开发分支中添加了这两个文件。
场景 - 2
当我使用以下命令运行我的用户服务微服务项目时:
mvn clean spring-boot:run -Dspring.profiles.active=development
它从git获取了正确的文件,但它从主分支检出!而不是从开发分支,这正是我期望的。我是否期望正确?(FYI,我在主分支中既有开发版yml又有生产版yml)
那么问题是,我们如何使用配置服务器?是否有任何配置可以设置仅从特定分支获取yml?我相信我们需要设置一些标签,因为根据文档,默认标签为主分支。有人能告诉我如何在上述场景中设置标签吗?
spring.cloud.config
属性时有些令人困惑。 - Aman Guptaspring.cloud.config.label=release/1.0.0,release_1.0.0,release(_)1.0.0
但是不起作用。 - Nikhil Talrejarelease(_)1.0.0
。 - Nikhil Talrejaspring.cloud.config.branch
。 - Philip Rego