Spring Cloud Config Tutorial Using Git Repo | JavaInUse




Spring Cloud Config Example Using GIT Repo



In previous tutorial we implemented Spring Cloud Config using Native mode. We had also seen what need Spring Cloud Config fulfills. In this tutorial we will be implementing Spring Cloud Config using Git.

Spring Cloud - Table Of Contents

Microservice Registration and Discovery with Spring cloud using Netflix Eureka- Part 1. Microservice Registration and Discovery with Spring cloud using Netflix Eureka - Part 2. Microservice Registration and Discovery with Spring cloud using Netflix Eureka - Part 3. Microservice Registration and Discovery with Spring cloud using Netflix Eureka - Part 4. Spring Cloud- Netflix Eureka + Ribbon Simple Example Spring Cloud- Netflix Eureka + Ribbon + Hystrix Fallback Simple Example Spring Cloud- Netflix Hystrix Circuit Breaker Simple Example Spring Cloud- Netflix Feign REST Client Simple Example Spring Cloud- Netflix Zuul +Eureka Simple Example Spring Cloud Config Server using Native Mode Simple Example Spring Cloud Config Server Using Git Simple Example Spring Boot Admin Simple Example Spring Cloud Stream Tutorial - Publish Message to RabbitMQ Simple Example Spring Cloud Stream Tutorial - Consume Message from RabbitMQ Simple Example Spring Cloud Tutorial - Publish Events Using Spring Cloud Bus Spring Cloud Tutorial - Stream Processing Using Spring Cloud Data Flow

Video

This tutorial is explained in the below Youtube Video.

Lets Begin-

As discussed previously this is the module architecture we will be developing.

The steps we will be following for this tutorial will be-
  • Creating a Git Project. Creating the application.properties in this project
  • Modifying the employee-config-server module we created previously to use the application.properties from the Git Repo instead of Native files.
  • Configure the Git Repo 1. Got to GitHib. If already have an account login or else SignUp.
    2. Create a new repository named employee-config-server.
    3. Finally create anew file named application.properties, copy the global properties like Eureka url and commit this file.
    eureka.client.serviceUrl.defaultZone=http://localhost:8090/eureka
         

  • Next we will modify the employee-config-server module we created previously.
    1. From the src/main/resources/application.properties remove the native property and add the Git project url we just created as follows-
    server.port=8888
    spring.cloud.config.server.git.uri=https://github.com/JavaInUse/employee-config-server
     	
    2. We can now delete the common-config folders as the global properties will be read from Git Repo.
Next start the modules in following sequence-
  • employee-config-server
  • eureka-server
  • employee-producer
On running the employee-producer we get the output as follows-
The employee-producer module gets the eureka properties from the employee-config-server module and starts successfully.

Download Source Code

Download it -
Employee Config Server using Git
Employee Producer With Config Server
Eureka Server

See Also

Spring Boot Hello World Application- Create simple controller and jsp view using Maven Spring Boot Tutorial-Spring Data JPA Spring Boot + Simple Security Configuration Pagination using Spring Boot Simple Example Spring Boot + ActiveMQ Hello world Example Spring Boot + Swagger Example Hello World Example Spring Boot + Swagger- Understanding the various Swagger Annotations Spring Boot Main Menu Spring Boot Interview Questions