Skip to main content

How to create Spring boot cloud config server


What is Spring boot cloud config server?

Spring Cloud Config Server provides an HTTP resource-based API for external configuration (name-value pairs or equivalent YAML content). The server is embeddable in a Spring Boot application, by using the @EnableConfigServer annotation. Consequently, the following application is a config server
In Simple terms, Spring boot cloud config server takes your application.yml or application.properties from your spring boot application and serve it over HTTP, and spring application which need to use it just need to delete the application.yml or application.properties and create one bootstrap.yml/properties and defined 2 simple properties spring.application.name and spring.cloud.config.uri



  • Create New java project using one of following instructions.
  1. Create project with Java, maven and Intellij

  • Edit POM.xml, add following content in pom.xml
First specify the packaging

jar
also add parent of this pom to be
NOTE: You can lookup the latest version for parent from here, I will advise to use latest version if possible at the time of writing this article its 2.0.4.RELEASE.


Add Rest of dependencies Right Click on Java folder and create new Java file com.next.config.SpringCloudConfigServer
NOTE : the annotation to enable config server



Add application.yml file in resources


Create Directory /tmp/config (if you are on Mac or Linux), on windows you can create directory like c:/tmp/config and update the application.yml with this path.

create a file application.yml in directory /tmp/config or c:/tmp/config
I am adding only one property for simplicity, but feel free to add as many as you like.

once file is created, initialise the git on this folder by running following commands.
Now the server is ready with minimum capabilities, that it can serve this application.yml from /tmp/config folder via http.

Start the server by right clicking on java file SpringCloudConfigServer and select Run,
once started visit http://localhost:8888/application/profile (basically url structure is http://localhost:8888/<application name>/<profile name(s)> and this will show you the content of /tmp/config/application.yml in format something like this

We have just seen simplest implementation of Spring Cloud Config server, this server doesn't care what application name or profile you passed to it, it will always return content of /tmp/config/application.yml which is not suitable for a production setup, as you may want to run multiple application in multiple environments(profiles).

I will explain such scenario in next section.

Comments

  1. Great job, You are providing good knowledge. It is really helpful and factual information for us and everyone to increase knowledge. Continue sharing your data. Thank you. IT support and services

    ReplyDelete
  2. The great service in this blog and the nice technology is visible in this blog. I am really very happy for the nice approach is visible in this blog and thank you very much for using the nice technology in this blog
    Best Project Management Software

    ReplyDelete
  3. I really want to thank the author for such a nice blog that helped me to understand why it is important. Oracle Manufacturing Cloud training in bangalore

    ReplyDelete
  4. I will share it with my other friends as the information is really very useful. Keep sharing your excellent work. it outsourcing

    ReplyDelete
  5. I read this article, it is really informative one. Your way of writing and making things clear is very impressive. Thanking you for such an informative article.New Mumbai Flats

    ReplyDelete
  6. You shared an excellent article with us. This article gives some unique knowledge to us. Keep sharing more posts.
    Best UPVC Windows and Doors Manufacturer in Chennai | Latest Upvc Doors in Chennai
    | Best UPVC Windows in Chennai

    ReplyDelete
  7. I am thankful to this blog giving unique and helpful knowledge about this topic. softphone

    ReplyDelete
  8. Impressive and powerful suggestion by the author of this blog are really helpful to me. NEC Phones Brisbane

    ReplyDelete
  9. Your blog contains lots of valuable data. It is a factual and beneficial article for us.MSP Service Thankful to you for sharing an article like this.

    ReplyDelete
  10. These types of suggestions are very useful to me. You are providing good knowledge about Graphic Design Agency Miami. I hope everyone will enjoy this article as much as me. Thank you for sharing this with you.

    ReplyDelete
  11. Cloud technology has revolutionized all fields connected to the Internet. I had some questions about the spring boot cloud config server and Buy Dissertation Online, and after reading your blog, everything has been cleared.

    ReplyDelete
  12. You have shared a magnificent post about Cloud Hosting Cpanel I totally agree with all the points you mentioned here. Thank you for providing such an informative post.

    ReplyDelete
  13. I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.Accounting Solutions Company in India

    ReplyDelete
  14. Your blog contains lots of valuable data. It is a factual and beneficial article for us.Backup disaster Recovery solutions in Houston Thankful to you for sharing an article like this.

    ReplyDelete
  15. The information in the post you posted here is useful because it contains some of the best information available. Saudi Arabia Vps. Thanks for sharing it. Keep up the good work.

    ReplyDelete
  16. You wrote this post very carefully. The amount of information is stunning and also a gainful article for us. Keep sharing this kind of articles, Thank you.Buy Dedicated Server In Istanbul

    ReplyDelete
  17. There are a few things to keep in mind when using an international eSIM card. First, you will need to have a compatible device. Second, you will need to activate the eSIM card in the country you are travelling to. Travel eSIM Card

    ReplyDelete
  18. In arrange to put through our machines to the Web, we can’t continuously depend on a settled Web association; in numerous circumstances, a cellular association would be distant more advantageous. That being said, a standard portable SIM card doesn’t offer you the same basic highlights and functionalities that an M2M SIM does.

    ReplyDelete
  19. Nice and interesting information and informative too.
    Vonex phones

    ReplyDelete
  20. Our Toilet Brushes mission is to help folks make issues, and we’ve at all times felt entry to CNC gear is vital thing}. As the default, Tormach gear is shipped in crates and owners assemble and commission machines. Start with PathPilot®, Tormach’s in-house control software program and the mind of every Tormach.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to add custom user attributes in keycloak and access them in spring boot application

Sometime it may be possible you want to add more parameters to standard registration page of keyloak for your users and aaccess that data in your spring boot application. This artical will show step by steps on how to add such extra attributes. What is Keycloak Keycloak is an open source software product to allow single sign-on with Identity Management and Access Management aimed at modern applications and services, to learn more visit  h ttps://www.keycloak.org/ What is Spring boot Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run". To learn more visit  https://spring.io/projects/spring-boot To add an extra attribute in keyclkoak server you will need to edit actuall html template and then registaer new attribute in json response so that it will be available on client. Edit HTML template Lets assume we want to add mobile number on default registration page. Go to Keycloak home installation directory edit fil

How to create java maven project in intelij

Open intellij Create a new java maven project in intellij . Select Maven type, Select JDK you want to use and click Next. Enter GroupId and ArtifactId, click Next Select project Location and click finish Intelij will display a warning, just press Ok. Once project is created , a popup may appear asking for auto import, select "Enable Auto Import" You will have a project created, looking something like this Note: I have created these instructions using, Instruction for other OS or intellij Version shouldn't be much different, if you need instruction for other version leave a comment and i will try to come up with another set of instructions. Intellij 2017.2.1 Java 1.8 Mac OS

Static and final, when and how to use

Usually when some one ask a simple question when you will make variable or function as static , a simple answer comes to mind   Variables : when i want to make single instance of that variable shared across all objects of this class. Good answer :)  Functions : When i want to access a function of class without creating its object. Good answer :)  Currently not talking about classes  Both are good answer but not complete. There are more things static do behind the screen then things mentioned above. Static fields will not be serialised. Check Following code Class ClassWithStaticFunction{ public void doSomething(){ ...     doSomethingMore(); ... } private void doSomethingMore(){ ... ... } } In above example a developer can say i can't make it better performance unless you tell me what these functions are doing(... lines), but that's incorrect you can make it performant without knowing about what goes inside it.  When a function is made static as a develo