Spring Cloud config configuration refresh

Source: Internet
Author: User
Tags bind
Spring Cloud config configuration refresh

The client refreshes the operation.

1. Add the actuator package so that the/refresh URL is in the available state.

1 2 3 4 <dependency> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-starter -actuator</artifactid> </dependency>


2, the manual test, turn off the rights authentication, otherwise access will appear without permission.

1 2 3 Management:security:enabled:false

3, add @refreshscope annotations on the controller, add @refreshscope class will be special processing when configuration changes.

Whether it can be used on other configured classes is not tested.

1 2 3 4 5 6 7 8 9 Ten-All-in-one package  com.thuniso Ft.thunisoftmicroservicetestconfig.controller;   import  Org.springframework.beans.factory.annotation.Value; import  Org.springframework.cloud.context.config.annotation.RefreshScope; import  org.springframework.web.bind.annotation.GetMapping; import  Org.springframework.web.bind.annotation.RestController;   @RefreshScope @RestController public  class  displayconfigcontroller {        @Value ("${profile}")      private  String profile;  

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.