英文:
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
答案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
我遇到了相同的问题,并通过进行以下两个更改来解决:
- 
spring.cloud.config.server.git.uri=E:/spring_microservice/git-localconfig-repo - 
在所有地方添加正斜杠(
/)。 
英文:
I was getting the same issue, and resolved it by making the two below changes:
- 
spring.cloud.config.server.git.uri=E:/spring_microservice/git-localconfig-repo - 
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论