A Spring @Bean that is marked as @RefreshScope will get special
treatment when there is a configuration change. This addresses the
problem of stateful beans that only get their configuration injected
when they are initialized. For instance if a DataSource has open
connections when the database URL is changed via the Environment, we
probably want the holders of those connections to be able to complete
what they are doing. Then the next time someone borrows a connection
from the pool he gets one with the new URL.
The RefreshScope is a bean in the context and it has a public method
refreshAll() to refresh all beans in the scope by clearing the target
cache. There is also a refresh(String) method to refresh an individual
bean by name. This functionality is exposed in the /refresh endpoint
(over HTTP or JMX).