Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring config @RefreshScope

Can I use @RefreshScope (along with @Value on a property) only in Cloud config server or can I use without config server as well? I'm trying to use it without config server. I am trying to fetch @Value property by changing value in a .property file and trying to request again, will I get updated value? Is that possible?

like image 306
Abhi Avatar asked Jul 15 '26 12:07

Abhi


1 Answers

No, you should use it along with Config server otherwise you won't be able to read the update properties on fly. Follow this article and have a look into this if you face any issue loading updated properties dynamically.

In theory, you could refresh the application context, but I wouldn't recommend this. Spring Cloud has provided an annotation to mark a bean as refreshable. By adding spring actuator, we can refresh those beans on the fly.

like image 123
Bilal Ahmed Yaseen Avatar answered Jul 17 '26 17:07

Bilal Ahmed Yaseen