javaspringspring-cloud-config-server

Spring Cloud Config on GitHub


I'm having problems fetching config files from my remote repo on github.

Spring Cloud Config

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.3.4</version>
        <relativePath/>
    </parent>

<properties>
        <java.version>17</java.version>
        <spring-cloud.version>2023.0.2</spring-cloud.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>


    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
server:
  port: 8888

spring:
  application:
    name: ConfigServer

  cloud:
    config:
      server:
        git:
          uri: ${GITHUB_URI}
          username: ${GITHUB_USERNAME}
          password: ${GITHUB_PASSWORD}
          skip-ssl-validation: true
          clone-on-start: true
          default-label: main



logging:
  level:
    org.springframework.cloud.config.server: TRACE
    org.eclipse.jgit: TRACE

The config server seems to correctly authenticate to github, if I change anything about the uri, username or password, I get an Unauthorized exception on startup, so that should be ok.

The repo I'm pointing to on github has the only branch 'main' and contains at the moment just one file named 'application.yml'.

Now the weird thing is, when I search for a random path the call goes 404 immediatly:

$ curl http://localhost:8888/safassdfa
{"timestamp":"2024-10-12T15:52:28.460+00:00","status":404,"error":"Not Found","path":"/safassdfa"}

But when I try a path that should exist the call hangs until a timeout occurs:

$ curl http://localhost:8888/default/application

OR

$ curl http://localhost:8888/main/application.yml

both go timeout and in the config server logs I see:

2024-10-12T17:58:14.279+02:00  INFO 19170 --- [ConfigServer] [nio-8888-exec-6] o.s.c.c.c.ConfigServerConfigDataLoader   : Exception on Url - http://localhost:8888:org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://localhost:8888/application/default": Read timed out. Will be trying the next url if available
2024-10-12T17:58:14.279+02:00  WARN 19170 --- [ConfigServer] [nio-8888-exec-6] o.s.c.c.c.ConfigServerConfigDataLoader   : Could not locate PropertySource ([ConfigServerConfigDataResource@2e510fa3 uris = array<String>['http://localhost:8888'], optional = true, profiles = 'default']): I/O error on GET request for "http://localhost:8888/application/default": Read timed out

Solution

  • The web starter dependency is apparently necessary and was missing. Adding it fixed the problem.

    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>