Prudvinath
Prudvinath

Reputation: 15

Spring Boot - Cloud : /actuator/refresh working but not able to get the changed values on the fly

I'm learning Spring Boot/cloud/Microservices and I'm very new to this.

As the title says, I'm not able to refresh properties on the fly.

I'm using spring boot 2.0.0.RELEASE and spring cloud Finchley.M8, I updated the bootstrap.properties as below:

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

I'm sending a POST request to /actuator/refresh URL to ensure that properties are refreshed.I'm using the @RefresheScope, on Configuration class.

The post request on actuator/refresh is returning (I'm using postman)

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

But, the request to the my service is not picking up these updated properties.

Please let me know if I am missing something.

Upvotes: 1

Views: 5492

Answers (3)

shubh gaikwad
shubh gaikwad

Reputation: 187

If you are using @Value to get properties then consider adding @RefreshScope at class level.

Upvotes: 0

Lyman
Lyman

Reputation: 76

I have a same problem, and if you are using a @Value to initialize like I do, maybe you could add a @RefreshScope in your class. https://www.devglan.com/spring-cloud/refresh-property-config-runtime this is for reference

Upvotes: 2

Hope Dc
Hope Dc

Reputation: 11

I use spring-boot 2.0.1,and my request is /refresh and it's works ok.you can try again. Or you can use spring-boot 2.0.0 and try /refresh.

Upvotes: 0

Related Questions