【问题标题】:How to escape a slash character within a branch name (label) in Spring Cloud Config如何在 Spring Cloud Config 中的分支名称(标签)中转义斜杠字符
【发布时间】:2017-09-12 03:38:03
【问题描述】:

在 Spring Cloud Config 中,如果您有一个包含 / 的分支(标签),它不会从云配置服务器获取正确的分支。

在我们的产品TheAppbootstrap.yml 中考虑以下属性;

spring:
  application:
    name: TheApp
  profiles:
    active: test
  cloud:
    config:
      uri: http://myconfigserver.com

我们为我的云配置标签包含分支feature/new,如下所示直接使用它;

spring:
  cloud:
    config:
      label: feature/new

因为这将转换为从我们的TheApp 应用程序对配置服务器的以下 RESTful 调用;

http://myconfigserver.com/{name}/{profile}/{label}

将会是;

http://myconfigserver.com/TheApp/test/feature/new

虽然很明显,由于我们的标签名称中有额外的/,这个调用将不起作用。如何在此配置中使用包含/ 的标签?

【问题讨论】:

    标签: spring spring-boot spring-cloud-config


    【解决方案1】:

    解决方案非常简单,只需将正在中断对配置服务器的调用的/ 替换为(_),例如feature/new 在我们的bootstrap.yml 中将是feature(_)new

    spring:
      cloud:
        config:
          label: feature(_)new
    

    对配置服务器的 RESTful 调用将是;

    http://myconfigserver.com/TheApp/test/feature(_)new
    

    这将导致成功获取正确的分支,即feature/new

    更多详情;检查herehere

    【讨论】:

      猜你喜欢
      • 2011-02-01
      • 2023-03-30
      • 2016-01-29
      • 2017-10-18
      • 2012-08-02
      • 1970-01-01
      • 2019-05-05
      • 2016-10-22
      相关资源
      最近更新 更多