【问题标题】:Spring Cloud Config Server: error: No such label: masterSpring Cloud Config Server:错误:没有这样的标签:master
【发布时间】:2021-02-06 21:36:04
【问题描述】:

当我访问网址 http://localhost:8888/actuator/health 时出现此错误

{
    "status": "DOWN",
    "details": {
        "diskSpace": {
            "status": "UP",
            "details": {
                "total": 457192763392,
                "free": 347865096192,
                "threshold": 10485760
            }
        },
        "refreshScope": {
            "status": "UP"
        },
        "configServer": {
            "status": "DOWN",
            "details": {
                "repository": {
                    "application": "app",
                    "profiles": "default"
                },
                "error": "org.springframework.cloud.config.server.environment.NoSuchLabelException: No such label: master"
            }
        }
    }
}

我的应用程序.yml

enter image description here

【问题讨论】:

  • 下次请将源代码以文本形式发布,而不是截图形式

标签: java spring server cloud config


【解决方案1】:

默认情况下,spring cloud server 会尝试从 git 仓库中的“master”分支获取属性。 Your repository 没有它(你有分支“main”)。

您可以使用属性default-label 设置自定义分支名称(参见docs):

spring:
  cloud:
    config:
      server:
        git:
          default-label: main

或者,您可以将分支重命名为 master 并保留所有其他内容。

【讨论】:

    【解决方案2】:

    你可以简单的在你的配置文件application.properties或者apllication.yml中添加如下代码:

    - 对于使用 application.properties 文件的人:

    spring.cloud.config.server.git.default-label=main

    - 对于使用 application.use 文件的人:

    弹簧: 云: 配置: 服务器: 混帐: 默认标签:主要

    【讨论】:

      【解决方案3】:

      检查您的属性文件名和请求文件名。 通过进行以下两项更改,我得到了相同的解决方案。

      第一个变化: spring.cloud.config.server.git.uri=E:\\\\spring_microservice\\\\git-localconfig-repo

      删除文件///......并添加了4个斜杠(\\)

      第二个变化: 实际上我正在使用不正确的属性文件名提出请求。我提出了像http://localhost:8888/limit-servers/default 这样的请求,但正确的文件名是limit-server.properties,所以我已经更正了如下请求。

      http://localhost:8888/limit-server/default
      

      它对我有用。

      【讨论】:

        猜你喜欢
        • 2016-09-26
        • 2016-06-04
        • 2016-10-22
        • 1970-01-01
        • 2020-11-26
        • 2018-05-30
        • 1970-01-01
        • 1970-01-01
        • 2021-10-09
        相关资源
        最近更新 更多