Https://www.cnblogs.com/hfultrastrong/p/8562320.html
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; |