Spring Cloud Config Server: 错误: 没有这个标签: master

huangapple go评论76阅读模式
英文:

Spring Cloud Config Server: error: No such label: master

问题

以下是您提供的内容的翻译:

当我访问URL 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"
            }
        }
    }
}

我的application.yml配置如下:点击此处查看图片描述

英文:

when I access the url http://localhost:8888/actuator/health y have this error

{
    "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"
            }
        }
    }
}

my application.yml

enter image description here

答案1

得分: 3

默认情况下,Spring Cloud 服务器尝试从 git 存储库的“master”分支获取属性。您的存储库 没有它(您有一个名为“main”的分支)。

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

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

或者,您可以将分支重命名为 master,然后将所有其他内容保持不变。

英文:

By default, spring cloud server tries to get properties from branch "master" in the git repository. Your repository doesn't have it (you have branch "main" instead).

You can use property default-label to set custom branch name (see docs):

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

Or, you can rename your branch to master and leave all other things as they are.

答案2

得分: 1

检查你的属性文件名和请求文件名。
我之前遇到了相同的问题,并通过以下两个更改解决了。

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

删除了 file///...... 部分,并添加了4个斜杠 (\\)。

第二个更改:
实际上,我之前用了错误的属性文件名发起了请求。我之前的请求是 http://localhost:8888/limit-servers/default,但正确的文件名应该是 limit-server.properties,所以我将请求更正如下。

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

这样就可以正常工作了。

英文:

Check your property file name and request file name.
I was getting same and resolved by making two below changes.

1st Change:
spring.cloud.config.server.git.uri=E:\\\\spring_microservice\\\\git-localconfig-repo

Removed file///...... and added 4 slash (\\)

2nd Change:
Actually i was making request with incorrect property file name. I was making request like http://localhost:8888/limit-servers/default but correct file name is limit-server.properties so i have correct the request as below.

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

And it worked for me.

答案3

得分: 1

我遇到了相同的问题,并通过进行以下两个更改来解决:

  1. spring.cloud.config.server.git.uri=E:/spring_microservice/git-localconfig-repo

  2. 在所有地方添加正斜杠(/)。

英文:

I was getting the same issue, and resolved it by making the two below changes:

  1. spring.cloud.config.server.git.uri=E:/spring_microservice/git-localconfig-repo

  2. Added forward slash (/) everywhere.

答案4

得分: 0

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

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

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

  • 对于使用application.yml文件的人:

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

英文:

You can simply add in your configuration file application.properties or apllication.yml, the following line of code :

- For people that use application.properties file :

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

- For people that use application.use file :

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

huangapple
  • 本文由 发表于 2020年10月24日 03:49:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/64506462.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定