spring config server- for local git repository

半腔热情 提交于 2021-01-29 11:22:08

问题


I'm trying to setting up spring cloud config server

-Created git repository folder on my local F:\git-local-repository\repository

-linked it using class path link source -Added property file for my service

-After committing my changes on location F:\git-local-repository\repository

-hitting url : http://localhost:8888/limits/default

result in error : org.springframework.cloud.config.server.environment.NoSuchLabelException: No such label: master

Caused by: org.eclipse.jgit.api.errors.RefNotFoundException: Ref master cannot be resolved

Following is my main class of spring boot application

@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

expected result: will be showing application property details and other url's


回答1:


The issue is with extra forward slash. Please change to this :

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



回答2:


If you are using a local directory for configuration.

Instead of

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

Use

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



回答3:


Adding bootstrap.yml file with following configuration worked for me.

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



回答4:


I had the same problem and it was because git change the default name of the branch, now it is main, while spring is searching for master.

Adding 'spring.cloud.config.server.git.default-label=main' fixed my problem.




回答5:


Did so many things to resolve this however it was adding

spring.cloud.config.server.git.default-label=main to application.properties worked



来源:https://stackoverflow.com/questions/57257587/spring-config-server-for-local-git-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!