Salman Saleem’s Post

Hitting /actuator/refresh updates the config server values — but your beans won't see the new values unless they're annotated with @RefreshScope. Without it, Spring initializes the bean once at startup, injects the property value at that point, and never touches it again. The refresh endpoint updates the Environment, but that bean is already holding a stale copy from startup. @RefreshScope solves this by making the bean a proxy. When a refresh is triggered, Spring destroys the scoped bean and recreates it on the next method call — picking up the latest values from the Environment. Two things worth knowing: 1. @ConfigurationProperties classes also need @RefreshScope if you want them to reload. The annotation alone isn't enough. 2. @RefreshScope on a @Configuration class doesn't automatically propagate to the beans it declares. Each bean that needs to reload must be scoped individually. #Java #SpringBoot #SpringCloud #BackendEngineering

  • text

To view or add a comment, sign in

Explore content categories