The Spring Cloud Config client uses

Source: Internet
Author: User

To use these features in your application, simply build them into a spring-guided application that relies on spring-cloud-config-client (for example, to view test cases for configuring a client or sample application). The most convenient way to add dependencies is through the Spring boot launcher org.springframework.cloud:spring-cloud-starter-config. There is also a MAVEN user's parent pom and BOM (spring-cloud-starter-parent) and a spring IO version management properties file for Gradle and spring CLI users. Example MAVEN configuration:

<parent> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-starter-p arent</artifactid> <version>1.3.5.RELEASE</version> <relativepath/> <!--lookup PA Rent from Repository-</parent><dependencyManagement> <dependencies> <dependency&gt            ; <groupId>org.springframework.cloud</groupId> <artifactid>spring-cloud-dependencies</artifa Ctid> <version>Brixton.RELEASE</version> <type>pom</type> < Scope>import</scope> </dependency> </dependencies></dependencymanagement><dependen cies> <dependency> <groupId>org.springframework.cloud</groupId> &LT;ARTIFACTID&GT;SP ring-cloud-starter-config</artifactid> </dependency> <dependency> <groupid>org.spring Framework.bOot</groupid> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scop e> </dependency></dependencies><build> <plugins> <plugin> & Lt;groupid>org.springframework.boot</groupid> <artifactid>spring-boot-maven-plugin</artifa Ctid> </plugin> </plugins></build>

Then you can create a standard spring boot application, like this simple HTTP server:

@SpringBootApplication@RestControllerpublic class Application {    @RequestMapping("/")    public String home() {        return "Hello World!";    }    public static void main(String[] args) {        SpringApplication.run(Application.class, args);    }}

When it runs it will receive the external configuration from the default local configuration server on port 8888 if it is running. To modify the startup behavior, you can use bootstrap.properties (such as application.properties) to change the location of the configuration server, but for the boot phase of the application context, for example

spring.cloud.config.uri: http://myconfigserver.com

The Boot property appears as a high-priority property source in the/env endpoint, such as

$ curl localhost:8080/env{  "profiles":[],  "configService:https://github.com/spring-cloud-samples/config-repo/bar.properties":{"foo":"bar"},  "servletContextInitParams":{},  "systemProperties":{...},  ...}

The property source named "configservice:< Remote Repository url>/< file name >" contains the property "foo" with the value "bar", which is the highest priority

Spring Cloud Config client use

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.