javaspringnetflix-eurekaspring-cloud-config-server

Eureka service not reading its config file in Git repository using ConfigServer


I'm trying trying to write some basic microservices examples. Firstly, I'm using a ConfigServer application using Spring, with this resources/application.yaml file:

server:
  port: 8081
spring:
  cloud:
    config:
      server:
        git:
          default-label: main
          uri: https://github.com/mguzm4n/microservices-data
          search-paths: config-data
  application:
    name: config-server

You can see the repo: https://github.com/mguzm4n/microservices-data

For Eureka, in resources/bootstrap.yaml:

spring:
  application:
    name: eureka-server
  cloud:
    config:
      enabled: true
      uri: http://localhost:8081

I build first ConfigServer App and then Eureka service, so it can load its config on Git, but I can't manage it to work. Eureka ends up running on localhost:8080 instead of port 8761 as shown in https://github.com/mguzm4n/microservices-data/blob/main/config-data/eureka-server.yaml.

Could anyone help me? I'm new using this concepts like a config server and eureka for registering other services, so I'm sorry if it's something simple.


Solution

  • Looks like your eureka-server is not picking up the bootstrapping config.

    First cause might be that this config file should be named bootstrap.yml, not bootstrap.yaml.

    Also, since Spring Boot 2.4 bootstrapping via bootstrap.yml is disabled by default and the usual application.yml should be used instead or it can be enabled back by adding the org.springframework.cloud:spring-cloud-starter-bootstrap dependency to your project.