Spring配置服务器- 用于本地Git存储库

3
我正在尝试设置Spring Cloud配置服务器。
- 在本地创建git存储库文件夹 F:\git-local-repository\repository - 使用类路径链接源将其链接起来 - 为我的服务添加属性文件
在提交更改到位置F:\git-local-repository\repository之后,访问URL:http://localhost:8888/limits/default 结果出现错误:
org.springframework.cloud.config.server.environment.NoSuchLabelException: No such label: master Caused by: org.eclipse.jgit.api.errors.RefNotFoundException: Ref master cannot be resolved
以下是我的Spring Boot应用程序的主要类。请注意保留html标签。
@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

期望的结果:将显示应用程序属性细节和其他网址。最初的回答。

请提及您的应用程序和引导程序。Yml文件。 - GnanaJeyam
更新的application.properties文件不使用bootstrap - kiran rathod
6个回答

3
如果您正在使用本地目录进行配置。
而不是
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

2
问题出在多余的正斜杠上。 请更改为以下内容:
spring.cloud.config.server.git.uri=file:///F:/git-local- 
repository/repository

1

我曾遇到同样的问题,原因是git更改了分支的默认名称,现在它是main,而spring正在寻找master。

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


0

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


-1

尝试了很多方法来解决这个问题,但是在application.properties中添加spring.cloud.config.server.git.default-label=main起作用了。


-1

使用以下配置添加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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接