Quick revision
The short answer
Organisations moved away from environment-specific builds because production then ran an artifact that had never been tested anywhere else; externalised configuration lets one artifact run everywhere, which suits containers. Feature flags then separated deploying code from releasing features and made gradual rollout possible. Today I would govern this with reviewed and audited configuration changes, flags that each have an owner and a removal date, secrets in a manager, and scheduled cleanup, because too many flags and profiles become debt.
What to remember
In this answer, we saw why organisations moved from environment-specific builds, where production ran an untested artifact, to externalised configuration, where one artifact runs everywhere and suits containers, and then to feature flags, which separate deploying from releasing and allow gradual rollout. The governance I would set today keeps configuration changes reviewed and audited, gives every flag an owner and a removal date, keeps secrets in a manager, and schedules cleanup so flags and profiles do not become debt.
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.
Organisations moved away from environment-specific builds because production then ran an artifact that had never been tested anywhere else; externalised configuration lets one artifact run everywhere, which suits containers. Feature flags then separated deploying code from releasing features and made gradual rollout possible. Today I would govern this with reviewed and audited configuration changes, flags that each have an owner and a removal date, secrets in a manager, and scheduled cleanup, because too many flags and profiles become debt.
Why this question is asked
How a company configures software shapes how safely it can release it. Over the last decade, practice moved from Maven profiles that produced a different war file for each environment, to one container image configured from outside, to feature flags that change behaviour without any deployment. Interviewers ask senior candidates to explain this shift because understanding why it happened is what lets us set rules that keep its benefits without its new problems. In this answer, we will look at the old model and its failure, the move to externalised configuration, what feature flags added, and then the governance I would set today, including how to keep flags from turning into debt.
1The Old Model: A Build Per Environment
Ten or fifteen years ago, it was common to build a different artifact for each environment. A Maven or Gradle profile swapped in a different properties file, and Spring profiles in the code activated different beans, so the build for production contained production URLs and production beans. It felt safe, because each environment had exactly what it needed.
The flaw was that the artifact deployed to production was never the artifact that had been tested. The test team approved build A, and production received build B, compiled separately with different resources. Any difference in dependencies, resources or build environment showed up first in production. Teams also accumulated beans that only existed in the production build, so production ran code paths no test had exercised.
2Externalised Configuration: One Artifact Everywhere
The answer was to build once and configure from outside. The same jar or container image moves through every environment unchanged, and the environment supplies its differences through environment variables, mounted files or a config server. Spring Boot's ordered property sources were designed for exactly this, and containers made it the natural model: an image is immutable, and Kubernetes injects configuration per deployment.
The benefit is that what we test is what we ship. If the image passed staging, the only differences in production are the values, and those are visible in one place. Profiles did not disappear, but their role shrank to real behaviour differences, such as fake integrations for local work.
| Era | What differs per environment | Main risk |
|---|---|---|
| Build per environment | The artifact itself | Production runs an untested build |
| Externalised configuration | Values injected at deploy time | Configuration mistakes and sprawl |
| Plus feature flags | Behaviour switched at runtime | Flag debt and hidden combinations |
3What Feature Flags Added
Externalised configuration still ties behaviour changes to a deployment: changing a value usually means restarting. Feature flags go one step further and separate deploying code from releasing a feature. The new code ships switched off, and the flag service turns it on for internal users, then for 5 percent of customers, then for everyone, while monitoring the effect. If something goes wrong, switching the flag off takes seconds and needs no rollback.
This made trunk-based development and continuous delivery practical, because half-finished work can merge and deploy behind a flag. But it also moved behaviour into a runtime system that is not in the code review, and every flag doubles the number of paths the code can take.
4The Governance I Would Set Today
Governance here means a few rules that keep the benefits without the risks. First, configuration changes are reviewed and audited: values live in version control, changes go through pull requests, and production consoles are not edited by hand. Flag changes in the flag service are logged with who, when and why, and risky flags need a second person to approve going to 100 percent.
Second, every flag has an owner and a removal date when it is created. A release flag, used to roll out a feature, should be removed a few weeks after full rollout. Operational flags, such as kill switches for an expensive integration, may live long, but they are labelled as such. Third, secrets are in a secrets manager with rotation, never in configuration files or flags. And fourth, profiles in code are limited to behaviour differences with feature names, so the environment model stays simple.
- Create flagowner, purpose, removal date
- Ship code behind it, flag offdeploy is not release
- Roll out graduallyinternal users, 5 percent, 50 percent, all
- Fully on for two weeks?YesRemove the flag and the old code pathNoKeep monitoring
- Past removal date?YesOwner is reminded, then escalatedNoNothing to do
5 steps in order. Play them, or step through them one at a time.
5Keeping Flags and Profiles From Becoming Debt
Flags and profiles are cheap to add and easy to forget. A company with 2,000 flags, half of them permanently on, has code full of dead branches and combinations nobody has tested. So cleanup must be scheduled, not hoped for. A monthly report lists flags past their removal date and flags unchanged for months, and teams remove them as normal work, tracked like any other backlog item. Some teams make a flag's removal ticket part of the definition of done for the feature.
The same applies to configuration keys and profiles: unused keys are found by comparing deployment values with the metadata services publish, and profiles outside the agreed feature list fail a build check. What we measure is the count of stale flags and configuration-related incidents over time, so we can see whether the governance works.
6Follow-up questions
Are feature flags a replacement for configuration?
No. Configuration describes the environment: URLs, sizes, credentials, and it rarely changes. Flags describe behaviour we want to change at runtime and roll out gradually. Putting environment values into a flag service makes them harder to review, and putting rollout switches into configuration makes every change a deployment.
How do you test code with many flags?
Test each flag's on and off paths in unit tests, and test the combination that production actually runs in integration tests. Removing flags promptly is the real answer, because the number of combinations grows quickly with each live flag.
When is a build per environment still justified?
Rarely in services. It can be justified for clients that cannot read external configuration, such as some embedded systems, or for regulatory builds that must exclude code. Even then, the build should come from the same commit through the same pipeline.
7Conclusion
In this answer, we saw why organisations moved from environment-specific builds, where production ran an untested artifact, to externalised configuration, where one artifact runs everywhere and suits containers, and then to feature flags, which separate deploying from releasing and allow gradual rollout. The governance I would set today keeps configuration changes reviewed and audited, gives every flag an owner and a removal date, keeps secrets in a manager, and schedules cleanup so flags and profiles do not become debt.
Open with
The shift happened because of one weakness in the old model. With environment-specific builds, a Maven profile or Spring profiles produced a different artifact for production, so production ran something that had never been tested.
Then, if they want more
Externalised configuration fixed that: we build once, and every environment supplies its own values from outside, which is exactly how containers work, since an image is immutable and the platform injects configuration.
Feature flags went one step further: they separate deploying code from releasing a feature, so new code ships switched off and is turned on gradually, for internal users, then a small percentage, then everyone, with a kill switch if something goes wrong.
That enabled trunk-based development, but it also moved behaviour into a runtime system outside code review and multiplied code paths. So the governance I would set has four parts. Configuration changes are versioned, reviewed and audited, and flag changes are logged with an approval for risky ones.
Every flag gets an owner, a purpose and a removal date at creation, with release flags removed shortly after full rollout. Secrets live in a secrets manager with rotation. And cleanup is scheduled: a regular report of stale flags and unused keys, worked through as normal backlog, because too many flags and profiles quietly become technical debt.
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 Framework reference, Core technologies
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 "Over a decade, many organisations have moved from environment-specific builds and...": https://scrivio-interview-library.netlify.app/spring-boot/spring-configuration/94863fbc7f/