繁体   English   中英

@refreshScope Spring 云配置不刷新 application.properties 值

[英]@refreshScope Spring cloud config doesn't refresh application.properties value

我尝试在我的 rest controller 上使用注释 @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'

谢谢你们

解决了。

我将我的应用程序名称文件(客户端)从 application.yml 更改为 bootstrap.yml

现在当我运行 localhost:8081/actuator/refresh 我得到了这个响应

[
"config.client.version",
"data",
"spring.cloud.bootstrap.enabled"
]

谢谢你们

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM