Spring Cloud Config Tutorial (iv) Quick Start

Source: Internet
Author: User

Spring Cloud Config provides server and client support for external configurations in distributed systems. With config Server, you can manage the external properties of your application in all environments. The conceptual mappings on the client and server are the same as spring Environment and PropertySource abstraction, so they fit well with spring applications, but can be used with any application that runs in any language. As your application passes through the deployment process from developer to test and production, you can manage the configuration between these environments and determine everything that your application needs to run when it is migrated. The default implementation of the server storage backend uses git, which makes it easy to support the configuration environment for the label version and access to the various tools for managing content. It is easy to add an alternative implementation and insert it using the spring configuration.

Start the server:

$ cd spring-cloud-config-server$ ../mvnw spring-boot:run

The server is a spring boot application, so you can run it from the IDE instead of liking it (the main class is ConfigServerApplication ). Then try a client:

$ curl localhost:8888/foo/development{"name":"development","label":"master","propertySources":[  {"name":"https://github.com/scratches/config-repo/foo-development.properties","source":{"bar":"spam"}},  {"name":"https://github.com/scratches/config-repo/foo.properties","source":{"foo":"bar"}}]}

The default strategy for locating resources is to clone a git repository (in spring.cloud.config.server.git.uri ) and use it to initialize a mini SpringApplication . A small application is Environment used to enumerate property sources and publish through JSON endpoints.

The HTTP service has resources in the following format:

/{application}/{profile}[/{label}]/{application}-{profile}.yml/{label}/{application}-{profile}.yml/{application}-{profile}.properties/{label}/{application}-{profile}.properties

Where "Application" is SpringApplication injected as in spring.config.name (that is, the regular spring boot application is typically "application"), the profile is the active profile (or a comma-separated list of properties), and "label" is an optional git tag (default is "Master").

The Spring Cloud Config server provides configuration for remote clients from a git repository (must be provided):

spring:  cloud:    config:      server:        git:          uri: https://github.com/spring-cloud-samples/config-repo

SOURCE Source

Spring Cloud Config Tutorial (iv) Quick Start

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.