Unified Spring Cloud Configuration

Source: Internet
Author: User

Unified Spring Cloud Configuration

This article uses Spring Cloud for centralized configuration management, removes the previous configuration files from the project and puts them in git or svn for centralized management. when changes are required, various Applications can be notified, and the application does not need to be restarted to refresh the configuration.

Apply the following figure to see what we need to do:

Git Repository is the place where the configuration is stored. You can also select SVN.

Next, we create a multi-module Maven project, including sample-cloud-all, sample-cloud-configserver, and sample-cloud-client. The overall structure is as follows:

Config-repo is the storage location of the configuration file. It is not a Maven project, but for local modification and submission convenience.
The overall Source Code address is on Github, so this article will not post code

So far, config-server and config-client have been completed and can be used properly.

Let's talk about the basic principles:
Store our remote configuration file on git
Config-server connect to git
Config-client connects to config-server
When we start the config-client service, the client obtains the configuration file above the remote git through the connected config-server, and then loads it to the object through Spring. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4NCjxociAvPg0KPHA + expires + zvG1xMfpv/bPwsjDz + 7Ev9bQ0v3Tw7XExeTWw9DFz6K4/expires "brush: java;"> org.springframework.boot spring-boot-starter-actuator true

Then, use the annotation @ RefreshScope to modify the configuration variables automatically updated in the Java class.

After updating the configuration file in git, execute the POST request http: // localhost: 8080/refresh on the config-client side to update and refresh the configuration variable to the memory.

If we use the config-client for distributed deployment, it is not the best way to POST/refresh requests to every machine.
Spring Cloud Bus solves this problem for us.

First, let's look at the applied figure below:
The component can be used as a proxy.

After understanding and testing the unified Configuration Management of Spring Cloud, I found that this is not good, especially in distributed deployment, although it is fully supported, it is always difficult to use.

We recommend that you use Baidu's open-source Disconf for centralized configuration management. This is also mature, and many commercial projects are already in use.

At present, Spring Cloud is not yet mature, so we are slowly learning and researching, and the bloggers also look forward to Spring Cloud's truly powerful day by day.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.