Spring cloud, config server can not start, how to config uri for git
Asked Answered
M

5

10

I am pretty interested in spring cloud project and now I am testing it, but blocked immediately.

  1. In POM: I added this dependency:
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-config-server</artifactId>
</dependency>
  1. For main application:
@Configuration
@EnableAutoConfiguration
@EnableConfigServer
public class SpringConfigServerApplication {

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

So based on the documentation, I just need to add enableConfigServer, then I tried to start it, this is the error:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'environmentRepository' defined in class org.springframework.cloud.config.server.ConfigServerConfiguration$GitRepositoryConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalStateException: You need to configure a uri for the git repository

So, how can I config a uri for git repository? There is nothing mentioned in the documentation.

Thanks for more clarification

Mammary answered 28/3, 2015 at 19:5 Comment(1)
You can mention it in application.yml as spring.cloud.config.server.git.uri. Even I am trying to get a hold on this subject, This resource helped me a lot, You should try it out as well [Spring-Cloud Sample]qiita.com/making@github/items/…Waybill
G
13

Our example is here. The configuration from application.yml looks like this:

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/spring-cloud-samples/config-repo
Gavial answered 30/3, 2015 at 14:6 Comment(5)
Thanks for this info. but I have one issue, that its only fetch master branch from repository not the development or other based on the profiles. How can we specify profile specific git uri and branch ?Nutrilite
Ok I got it. Its basically label which I had to set under uri and since config server already open resource such as /{label}/{name}-{profiles}.yml by default label goes to master as per doc.Nutrilite
@Gavial so for adding encryption/decryption mechanism I added keystore [*.jsk] in the classpath but couldnot start the application due to unsatisfied dependency. I added rsa dependency but still seeing the same error. could you comment or should I take it as a new question?Chartres
Any quick help here - Caused by: org.eclipse.jgit.api.errors.RefNotFoundException: Ref master cannot be resolved?Bloodstream
see github.com/spring-cloud/spring-cloud-config/issues/…Gavial
P
4

I had the same issue and it was resolved when I set the profile in application.yml file as below:

spring:  
 profiles:   
  active: native
Petal answered 17/2, 2021 at 13:20 Comment(0)
H
0

Adding this solves issue

in yml

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/user/microservices-central-config-repourl.git
          clone-on-start: true
          default-label: main

OR

in property file

spring.cloud.config.server.git.default-label=main
Hillyer answered 21/7, 2022 at 3:47 Comment(0)
P
0

Change your branch name from main to master from your repository, it will solve problem

Phocis answered 6/8 at 12:3 Comment(0)
R
-4

About this serious problem, all you need to do is clean your maven repository and update it one again. That's worked for me !!

Rundgren answered 24/7, 2016 at 10:19 Comment(1)
Please, enhance your answer by adding more info about solution to the questionRemovable

© 2022 - 2024 — McMap. All rights reserved.