Spring 启动 - 云:/actuator/刷新工作,但无法即时获取更改的值



我正在学习Spring Boot/cloud/Microservices,我对此很陌生。

正如标题所说,我无法即时刷新属性。

我正在使用 spring boot 2.0.0.RELEASE 和 spring cloud Finchley.M8,我更新了 bootstrap.properties,如下所示:

spring.application.name=XXXXX
spring.cloud.config.uri=http://localhost:8888
management.endpoints.web.exposure.include=*
management.security.enabled=false
endpoints.actuator.enabled=true

我正在向 URL 发送 POST 请求/actuator/refresh以确保刷新属性。我在配置类上使用@RefresheScope

actuator/refresh上的帖子请求正在返回(我正在使用邮递员(

[
    "config.client.version",
    "updated property on GIT"
]

但是,对我的服务的请求不会选取这些更新的属性。

如果我错过了什么,请告诉我。

我有一个同样的问题,如果你像我一样使用@Value进行初始化,也许你可以在你的类中添加一个@RefreshScope。https://www.devglan.com/spring-cloud/refresh-property-config-runtime 这是供参考的

>我使用 spring-boot 2.0.1,我的请求是/刷新,它工作正常。或者你可以使用 spring-boot 2.0.0 并尝试/refresh。

如果使用@Value来获取属性,请考虑在类级别添加@RefreshScope。

最新更新