【问题标题】:spring config server- for local git repositoryspring config server- 用于本地 git 存储库
【发布时间】:2019-12-07 00:21:42
【问题描述】:

我正在尝试设置 spring 云配置服务器

-在我的本地创建 git 存储库文件夹 F:\git-local-repository\repository

-使用类路径链接源链接它 -为我的服务添加了属性文件

-在位置 F:\git-local-repository\repository 提交我的更改后

-点击网址:http://localhost:8888/limits/default

导致错误: org.springframework.cloud.config.server.environment.NoSuchLabelException:没有这样的标签:master

原因:org.eclipse.jgit.api.errors.RefNotFoundException: Ref master 无法解析

以下是我主要的spring boot应用类

@EnableConfigServer


@SpringBootApplication
public class SpringCloudConfigServerApplication {

public static void main(String[] args) {
    SpringApplication.run(SpringCloudConfigServerApplication.class, args);


}

}

application.properties

spring.application.name=spring-cloud-config-server

server.port=8888

spring.cloud.config.server.git.uri=file:////F:/git-local- 
repository/repository

预期结果:将显示应用程序属性详细信息和其他 url 的

【问题讨论】:

  • 请提及您的应用程序和引导程序。 yml文件
  • 更新的 application.properties 文件不使用引导程序

标签: java spring git microservices spring-boot-2


【解决方案1】:

如果您发出 NoSuchLabelException,您可以尝试添加 spring.cloud.config.server.git.default-label=branch-name 属性以将您的 spring 云配置服务器直接引导到此分支。

【讨论】:

    【解决方案2】:

    做了很多事情来解决这个问题,但是它正在添加

    spring.cloud.config.server.git.default-label=main 到 application.properties 工作

    【讨论】:

      【解决方案3】:

      我也遇到了同样的问题,因为git更改了分支的默认名称,现在是main,而spring正在搜索master。

      添加 'spring.cloud.config.server.git.default-label=main' 解决了我的问题。

      【讨论】:

        【解决方案4】:

        使用以下配置添加 bootstrap.yml 文件对我有用。

        spring:
           application:
                name: spring-cloud-config-server
        profiles:
        active: composite
        cloud:
         config:
          server:
            composite:
              - type: native
                search-locations: file:////F:/git-local-repository/repository
                  bootstrap: true
        server:
          port: 8888
        endpoints:
          restart:
             enabled: true
        

        【讨论】:

          【解决方案5】:

          问题在于额外的正斜杠。 请改成这样:

          spring.cloud.config.server.git.uri=file:///F:/git-local- 
          repository/repository
          

          【讨论】:

            【解决方案6】:

            如果您使用本地目录进行配置。

            代替

            spring.cloud.config.server.git.uri=file:////F:/git-local-repository/repository
            

            使用

            spring.cloud.config.server.native.search-locations=file:////F:/git-local-repository/repository
            

            【讨论】:

              猜你喜欢
              • 2019-06-30
              • 2020-07-23
              • 2021-08-13
              • 1970-01-01
              • 2016-09-09
              • 2023-04-06
              • 2023-03-20
              • 2020-11-13
              • 2015-05-21
              相关资源
              最近更新 更多