Quick revision
The short answer
A Spring Boot client imports its configuration at startup with spring.config.import=configserver:http://..., and the Config Server answers with property sources for the client's application name, active profiles and label, read from a backend such as Git, Vault or the filesystem. Later, POST /actuator/refresh makes one instance fetch the configuration again: @ConfigurationProperties beans are rebound and @RefreshScope beans are recreated, while ordinary beans keep their old values. Spring Cloud Bus can broadcast the same refresh to every instance.
What to remember
In this answer, we saw that a client imports its configuration from the Config Server at startup through spring.config.import, and that the server picks files by application, profile and label from a backend such as Git or Vault. We saw that POST /actuator/refresh updates one instance's Environment, rebinds @ConfigurationProperties beans and recreates @RefreshScope beans, while plain singletons keep their old values, and that Spring Cloud Bus spreads the same refresh to every instance through a broker.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
A Spring Boot client imports its configuration at startup with spring.config.import=configserver:http://..., and the Config Server answers with property sources for the client's application name, active profiles and label, read from a backend such as Git, Vault or the filesystem. Later, POST /actuator/refresh makes one instance fetch the configuration again: @ConfigurationProperties beans are rebound and @RefreshScope beans are recreated, while ordinary beans keep their old values. Spring Cloud Bus can broadcast the same refresh to every instance.
Why this question is asked
Configuration is the part of an application that changes most often without any code change: URLs, limits, feature switches, timeouts. Spring Cloud Config lets many services read it from one place, and it can even change values in a running application. Interviewers ask about it because the refresh part is easy to misunderstand: people expect every value to update, and then wonder why half of them did not. In this answer, we will recap what the Config Server serves, follow a client through startup, see what @RefreshScope really does, and then look at what /actuator/refresh and Spring Cloud Bus change and what they leave alone.
1A Quick Recap of the Config Server
The Config Server is a small Spring Boot application that serves configuration over HTTP. It does not hold the values itself. It reads them from a backend: most often a Git repository full of YAML or properties files, but it can also read HashiCorp Vault, a plain folder on disk (the native profile), a database and a few others.
Every request names three things. The application is the client's spring.application.name, for example orders. The profile is the client's active profile, for example prod. The label is a version in the backend, which for Git means a branch, a tag or a commit id, for example main. So the client asks for orders in prod at label main, and the server returns the matching files: application.yml (shared by everyone), orders.yml, and orders-prod.yml, with the more specific files taking precedence.
2How the Client Loads Configuration at Startup
On the client we add the spring-cloud-starter-config dependency and one property. The property spring.config.import tells Spring Boot to load an extra configuration source while it is preparing the Environment, the object that holds every property the application can see. The configserver: prefix names the Config Server as that source.
- Spring Boot reads application.ymlfinds
spring.config.import - Call GET /orders/prod/mainon the Config Server
- Config Server reads the backendGit, Vault or filesystem
- Property sources returned
orders-prod.yml,orders.yml,application.yml - Added to the Environmentwith higher precedence than local files
- Beans are createdand bind the values
6 steps in order. Play them, or step through them one at a time.
The configuration arrives before any bean is created, so beans see it from the start.
Notice the optional: prefix. Without it, startup fails when the server is down; with it, the application starts on its local values. Which one we want depends on whether the service is safe to run without its central configuration.
Older Spring Cloud versions used a separate bootstrap context and a bootstrap.yml file for this. Since Spring Cloud 2020.0 that is no longer the default: spring.config.import replaces it, and the bootstrap context only comes back if we add spring-cloud-starter-bootstrap or set spring.cloud.bootstrap.enabled=true. The values from the server are added to the Environment with a high precedence, so they win over the application's own application.yml.
3What @RefreshScope Does
Loading values at startup is the easy part. The interesting question is what happens when someone changes orders-prod.yml in Git while the application is running. Most beans in Spring are singletons: they are created once at startup, and a value injected with @Value is copied into a field at that moment. Changing the Environment later does not touch the field.
@RefreshScope is a scope, a rule for how long a bean instance lives, that solves this for chosen beans. Spring does not inject the bean itself into other beans; it injects a proxy, a small stand-in object that looks up the real bean on every method call. The real bean lives in a cache. When a refresh happens, the cache is cleared, and the next call through the proxy creates a fresh instance that reads the new values.
So the bean is not updated in place; it is thrown away and rebuilt. That is why @RefreshScope beans should be cheap to create and should not hold state we care about, such as an open connection or a counter, because that state is lost on each refresh.
4What /actuator/refresh and Spring Cloud Bus Change
The refresh endpoint is exposed by adding refresh to management.endpoints.web.exposure.include. When we send POST /actuator/refresh, the instance asks the Config Server for its configuration again, compares it with what it had, and updates its Environment. It then publishes an EnvironmentChangeEvent with the changed keys and clears the refresh scope. The response is the list of keys that changed.
Two kinds of bean react. Beans annotated with @ConfigurationProperties are rebound: Spring writes the new values into the existing object, so a class like OrdersProperties sees the new limit without being refresh-scoped. @RefreshScope beans are recreated, as we saw. Every other bean keeps the values it got at startup. A singleton service with @Value("${orders.max-items}") will go on using the old number until the application restarts, and this is the most common surprise.
The endpoint only refreshes the instance that received the request. With 20 instances we would have to call it 20 times. Spring Cloud Bus links the instances through a message broker, RabbitMQ or Kafka. We call POST /actuator/busrefresh on any one instance, it publishes a refresh event to the broker, and every instance that listens performs the same refresh. The Config Server can also trigger this itself from a Git webhook through its /monitor endpoint.
| Kind of bean | After POST /actuator/refresh |
|---|---|
@ConfigurationProperties bean | rebound: same object, new values |
@RefreshScope bean | destroyed; recreated on the next call with new values |
Singleton with @Value | unchanged until restart |
Environment.getProperty(...) calls | see the new value immediately |
5Follow-up questions
Why does my @Value field not change after a refresh?
Because the bean is a singleton and the value was copied into the field when the bean was created. The refresh updates the Environment, but nothing writes into that field again. Either annotate the bean with @RefreshScope, so it is rebuilt with the new value, or move the setting into a @ConfigurationProperties class, which is rebound on refresh and is usually the cleaner choice.
Do we still need bootstrap.yml?
Not by default. Since Spring Cloud 2020.0 the client uses spring.config.import in application.yml. The bootstrap context still exists for compatibility and is switched on with spring-cloud-starter-bootstrap or spring.cloud.bootstrap.enabled=true, which some setups need for older features, but new projects should use the import style.
Can a refresh change any property?
No. Values that were used once during startup, such as the server port, the data source URL of an already created connection pool, or beans that were already wired, do not change by refreshing. The refresh works well for values read at call time, such as limits, messages and feature switches. For the rest, a restart or a normal deployment is the honest way to apply a change.
6Conclusion
In this answer, we saw that a client imports its configuration from the Config Server at startup through spring.config.import, and that the server picks files by application, profile and label from a backend such as Git or Vault. We saw that POST /actuator/refresh updates one instance's Environment, rebinds @ConfigurationProperties beans and recreates @RefreshScope beans, while plain singletons keep their old values, and that Spring Cloud Bus spreads the same refresh to every instance through a broker.
Open with
The Config Server serves configuration from a backend, usually a Git repository, but also Vault or the filesystem. A client asks for its application name, its active profile and a label, which in Git is a branch or a commit, and gets back the matching files, with orders-prod.yml winning over orders.yml and the shared application.yml.
Then, if they want more
On the client side, today we set spring.config.import to configserver: and the server URL in application.yml; the old bootstrap context is no longer needed by default. I usually leave out the optional: prefix in production so a service never starts without its configuration. For runtime changes, POST /actuator/refresh makes that one instance fetch the configuration again and update its Environment.
Then two things happen. Beans with @ConfigurationProperties are rebound with the new values, and beans with @RefreshScope are thrown away and recreated on the next call, because they sit behind a proxy that looks them up from a cache that the refresh clears.
Ordinary singletons that took a value with @Value keep the old value until a restart, which is the usual surprise. Since the endpoint only affects one instance, Spring Cloud Bus is used to broadcast the refresh through RabbitMQ or Kafka with /actuator/busrefresh.
I would also be careful about what we allow to change at runtime, because a broadcast refresh changes every instance at once.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Cloud documentation, Resilience4j documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "How does a Spring Boot application load configuration from Spring Cloud Config Server...": https://scrivio-interview-library.netlify.app/spring-boot/spring-cloud/be2bee3d1f/