Microservice - Spring Cloud Configuration Server Using a GIT Store

Welcome to another video about microservices. Today we will learn about Spring Cloud Configuration and how we can use it to manage the confi...


Welcome to another video about microservices. Today we will learn about Spring Cloud Configuration and how we can use it to manage the configuration of our services. As per Spring, Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. Basically, what it means is that we can store and versioned the contents of the application property file in GIT. We can also update the configuration at run-time and it is accessible via GIT URI.

For this demonstration, we will need to set up 2 projects, one we should be already familiar with.
  1. Terawarehouse-catalog - this is our catalog microservice
  2. Terawarehouse-config-server - configuration server that reads the configuration from a GIT store

Setting up the Terawarehouse-config-server

  1. Add the spring-cloud-config-server dependency.
  2. Annotate the SpringBootApplication class with @EnableConfigServer.
  3. Configure the application.yml file. For this example, we will point the spring.cloud.config.server.uri to a local git repository (make sure to set it up first).
  4. Run the config server.
  5. Access the configurations via URL: http://localhost:8000/{applicationName}/{profile}.

Setting up the Terawarehouse-catalog project

  1. Add spring-cloud-starter-config dependencies.
  2. Annotate the SpringBoothApplication class with @EnableDiscoveryClient.
  3. In the resource folder, remove the application.yml or properties file and add a bootstrap.properties. In this file, we will be defining the application name as well as the config server URI.
    spring.application.name=catalog
    spring.cloud.config.enabled=true
    spring.cloud.config.uri=http://192.168.1.100:8000
    spring.cloud.config.fail-fast=true
  4. Create a new local git repository where the config server is pointing.
  5. Create a new file with filename equals to the spring.application.name of our microservice project. In this case catalog.
  6. Add all the required properties from the previous video we have. I already created a file named catalog.properties that you can download and paste in your local repository. Make sure to change the database configuration. Commit your changes.
  7. Our configuration should be accessible at http://localhost:8000/catalog/default.
  8. Let’s run the application. It should be accessible at port 8001.
  9. Stop the application.
  10. Let’s create a new profile “integration” with filename catalog-integration.properties and set the port to 8002.
  11. Run the application again and this time it should be available at port 8002.
That should do it for this video. Hoping that what I shared today could be of use to you tomorrow.

References

Repositories


For repositories use:
  • Broodcamp Utils - Release version 0.0.1
  • Broodcamp Commons - Release version 0.0.1
  • Terawarehouse (catalog, config-server) - Tag 24-Microservice_Spring_Cloud_Configuration_Server_Using_a_GIT_Store

COMMENTS

mas template
Name

amazon,1,angular,8,bigdata,2,business,1,course-spring,27,courses,6,database,4,docker,3,java,50,kafka,1,keycloak,4,microservices,5,mysql,1,neworking,1,nosql,2,php,1,pinned,2,react,3,server management,7,shared drive,1,spring,7,synology,1,troubleshooting,2,web,1,wordpress,1,
ltr
item
toztech: Microservice - Spring Cloud Configuration Server Using a GIT Store
Microservice - Spring Cloud Configuration Server Using a GIT Store
https://i.ytimg.com/vi/SFo_gh4FaFc/0.jpg
https://i.ytimg.com/vi/SFo_gh4FaFc/0.jpg
toztech
https://toztech.blogspot.com/2019/10/microservice-spring-cloud-configuration.html
https://toztech.blogspot.com/
https://toztech.blogspot.com/
https://toztech.blogspot.com/2019/10/microservice-spring-cloud-configuration.html
true
2554149350007112447
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content