Spring Cloud Build Client

Source: Internet
Author: User

After completing the above verification, make sure that the Configuration service center is working, and below we try to get the configuration information described above in the MicroServices app.

    • Create a spring boot application, named config-client , and introduce the pom.xml following dependencies in:
12345678910 <dependencies> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-web</artifactid> </dependency> <dependency> <groupid>org.springframework.cloud</groupid> <artifactid>spring-cloud-starter-config</artifactid> </dependency> </dependencies>
    • Create a Spring boot application main class, as follows:
12345678 @SpringBootApplication public class application { public static void main(string[] args) { new Springapplicationbuilder (Application.class). Web (True). Run (args); }
    • Create bootstrap.yml a configuration to specify where to get the configuration file config-server-git , for example:
1234567891011 Spring: Application: name:config-client Cloud: Config: uri:http://localhost:1201/ Profile:default Label:master Server: Port: 2001

The above configuration parameters correspond to the various parts of the configuration file stored in Git, as follows:

    • Spring.application.name: Part of the corresponding profile rule {application}
    • Spring.cloud.config.profile: Part of the corresponding profile rule {profile}
    • Spring.cloud.config.label: Part of the corresponding profile rule {label}
    • Spring.cloud.config.uri: config-server Address of the configuration center

It is important to note that the above properties must be configured in bootstrap.properties so that the configuration information in the Config-server is loaded correctly.

After you have finished writing your code, the reader can start Config-server-git, config-client, and we can see that the endpoint will return the configuration information obtained from the GIT repository:

123 {"profile": "Default"}

Alternatively, we can modify the Config-client profile to Dev to see the changes in the loading configuration.

From now on, I will record the process and the essence of the recently developed Springcloud micro-service cloud architecture, and help more friends who are interested in developing the Spring cloud framework, hoping to help more good scholars. Let's explore how the Spring cloud architecture is built and how it can be used in enterprise projects. SOURCE Source

Spring Cloud Build Client

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.