【发布时间】:2021-01-02 23:39:57
【问题描述】:
我尝试在我的休息控制器上使用注解@RefreshScope:
@RestController
@RefreshScope
public class SpringCloudControllerTest {
@Value("${data}")
private String value;
@GetMapping
public ResponseEntity<String> testPropertiesFile(){
return ResponseEntity.ok(value);
}
@Value 注释引用了我的远程存储库上的 application.properties:
management.endpoints.web.exposure.include=*
data=2
如果我以这种方式更改我的文件:
management.endpoints.web.exposure.include=*
data=3
并在我的客户端运行请求 http://localhost:8081/actuator/refresh 回应只是:
[
"config.client.version"
]
如果我运行请求,我没有看到任何关于我的更改的响应
localhost:8081
响应总是“2”
这些是我对客户端的依赖:
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-config', version: '2.2.6.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version:'2.3.7.RELEASE'
谢谢大家
【问题讨论】:
标签: java spring spring-boot-actuator spring-cloud-config