spring - 如何在 Spring Cloud Config 中转义分支名称(标签)中的斜杠字符

标签 spring spring-boot spring-cloud-config

在 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

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

最佳答案

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

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

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

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

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

了解更多详情;检查here ,和here .

关于spring - 如何在 Spring Cloud Config 中转义分支名称(标签)中的斜杠字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43435897/

相关文章:

java - Spring 3如何映射这个jsp中的form-post?

java - PUT 和 POST - 参数相同,但 PUT 请求错误

spring - 一种定向建模在使用Spring Data Redis时不拉取记录

java - ArangoDB Spring Data 2,java.lang.Object/无效的映射类型

spring - <表格:form have method GET or POST

Spring Batch - 读取多行日志消息

python-3.x - 使用 Python 解压从 JSON 获得的字典

java - Eureka+Cloud-Config 与 Wildfly 和部署顺序

spring-boot - 动态刷新spring boot配置

java - Gradle-无法确定合适的驱动程序类别