Skip to main content

Command Palette

Search for a command to run...

RefreshScope Annotation

Published
1 min readView as Markdown

Usually we do when application start, we will fetch the properties from the Config files like from another service this will pull the properties

What if i changes the configuration in the file did it again fetch how? it come?

Do say u will restart server again, my answer is @RefreshScope

this annotation what it helps means It helps to mark the bean which needs to be destroyed and recreated(with latest value) when refresh event occurs.

So Where do u use this refresh scope in the controllers? NO in Service No? because it will destroy the bean and create right so make sure this u have to use n the Configuration properties annotation along with that and By the help of the actuator there is custom endpoint to refresh the properties which we have to use in all the service where we fetching the properties and that config properties file also

Can we Instead of adding all the service Just in ConfigServer? yes By using Refresh Bus.