user3006967
user3006967

Reputation: 3545

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

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

Upvotes: 10

Views: 22431

Answers (5)

Shubham Kulthe
Shubham Kulthe

Reputation: 1

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

Upvotes: 0

robinleathal
robinleathal

Reputation: 251

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

Upvotes: 0

Agnasarp
Agnasarp

Reputation: 41

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

spring:  
 profiles:   
  active: native

Upvotes: 4

machal
machal

Reputation: 34

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

Upvotes: -4

spencergibb
spencergibb

Reputation: 25147

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

Upvotes: 13

Related Questions