4

I have followed this official tutorial Getting Started Centralized Configuration using spring boot 2.0.0.RELEASE and spring cloud Finchley.M8

But refreshing properties on the fly (Without restart) is not working. After Some debugging, I noticed that in method refresh() from ContextRefresher.class, it returns the changed keys correctly, but after reconstructing the bean annotated with @RefreshScope in the next use. It still sees the old value not the updated one.

Note: This was working perfectly with spring boot v 1.5.6 and spring cloud Edgware.RELEASE.

Any help please?

Thanks

2
  • 2
    there is a bug in boot 2.0.0.RELEASE Commented Mar 19, 2018 at 18:20
  • yes, I see. Will postpone the upgrade until things are stable. Thanks Commented Mar 20, 2018 at 6:56

3 Answers 3

7

It seems spring.cloud.config.uri in spring boot 2.0.1.RELEASE always looking for port 8888 and not accepting other values, so I put the below configuration (you can ignore it, as it is the default value for the client, and the server should run on port 8888)

spring: cloud: config: uri: http://localhost:8888 

I also tried to expose all other services in the client for testing as follows

management: endpoints: web: exposure: include: '*' 

or use the following to allow only refresh

management: endpoints: web: exposure: include: refresh 

Then called POST method not GET for refreshing

$ curl -X POST localhost:8080/actuator/refresh -d {} -H "Content-Type: application/json" 

Finally, it works.

Sign up to request clarification or add additional context in comments.

3 Comments

My problem was on version 2.0.0.RELEASE, maybe they fixed it in 2.0.1.RELEASE
I faced the same issue on the latest version, but I fixed it as above
I have tried now by running the config server on port 8888 with spring boot V 2.0.0.RELEASE and the problem is the same. I think they managed to make a fix some how in the newer version.
1

enter image description here

Instead of Method "POST" , use "OPTIONS" method to call the "actuator/refresh" for spring boot 2.0 or higher.

For lower versions (<2.0), use the endpoint "context/refresh"

Make sure , you have management.endpoints.web.exposure.include=* defined in application.properties.

Comments

1

Use below in application.properties-

management.endpoint.refresh.enabled=true management.endpoint.restart.enabled=true management.endpoint.health.enabled=true management.endpoint.health.show-details=always management.endpoint.info.enabled=true management.endpoints.web.exposure.include=info,health,refresh 

Using yaml configuration file it was not working for me and when switched to properties file, it worked with above configuration.

Thanks

1 Comment

Even I tried the same and surprisingly it worked for me. Surely its a bug

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.