Quick revision
The short answer
First check the name: by Spring Boot's documented rules, the environment variable for app.feature-enabled is APP_FEATUREENABLED, because dots become underscores and dashes are removed, while APP_FEATURE_ENABLED is the name for app.feature.enabled. Then check that the variable really exists in the running process, use the secured actuator env or configprops endpoints to see which source supplied the value, and look for a higher-priority source such as a command-line argument or a config server. Also remember that @Value has only limited relaxed binding while @ConfigurationProperties is fully relaxed, so the two can behave differently.
What to remember
In this answer, we investigated an environment variable that did not override application.yml. The first suspect was the name: by the documented rule app.feature-enabled maps to APP_FEATUREENABLED, while APP_FEATURE_ENABLED names app.feature.enabled, and any legacy fallback varies by version. Then we checked that the variable exists in the running process, used the secured env and configprops endpoints to see which source won, looked for higher-priority sources such as command-line arguments, and remembered that @Value has only limited relaxed binding.
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.
First check the name: by Spring Boot's documented rules, the environment variable for app.feature-enabled is APP_FEATUREENABLED, because dots become underscores and dashes are removed, while APP_FEATURE_ENABLED is the name for app.feature.enabled. Then check that the variable really exists in the running process, use the secured actuator env or configprops endpoints to see which source supplied the value, and look for a higher-priority source such as a command-line argument or a config server. Also remember that @Value has only limited relaxed binding while @ConfigurationProperties is fully relaxed, so the two can behave differently.
Why this question is asked
Environment variables are the normal way to configure a containerised Spring Boot application, and the rule that they override application.yml is something every team relies on. When an override seems to be ignored in production, the cost is real: a feature that should be on is off, or the reverse. Interviewers ask this to see whether we investigate systematically rather than restart pods and hope. In this answer, we will recap relaxed binding, look at the naming trap in this exact case, then check the process, ask the application which source won, look for higher-priority sources, and see how @Value and @ConfigurationProperties differ.
1A Quick Recap of Relaxed Binding
Environment variable names on most systems may only contain letters, digits and underscores, so they cannot hold app.feature-enabled directly. Spring Boot solves this with relaxed binding: it maps property names to environment variable names by a fixed rule. The documented rule is to replace dots with underscores, remove dashes, and convert to upper case. So the canonical name app.feature-enabled, written in kebab-case, becomes APP_FEATUREENABLED.
The important detail is that underscores in an environment variable mean dots. Spring Boot reads APP_FEATURE_ENABLED as the property app.feature.enabled, a property called enabled inside a group called feature, which is a different property from app.feature-enabled.
2The Naming Trap in This Case
That explains the most likely cause immediately. The deployment sets APP_FEATURE_ENABLED=true, and the application reads app.feature-enabled. By the documented mapping these are two different names, so application.yml's false is the only value for the key the code asks for.
| Environment variable | Property it supplies |
|---|---|
APP_FEATUREENABLED | app.feature-enabled (documented form) |
APP_FEATURE_ENABLED | app.feature.enabled |
APP_FEATURE_ENABLED | app.feature-enabled only via a legacy fallback in some versions |
APP_SERVERS_0_HOST | app.servers[0].host |
Some Spring Boot versions also try a legacy form that turns dashes into underscores, so the result for APP_FEATURE_ENABLED can differ between versions and between @Value and @ConfigurationProperties. That is exactly why we should not rely on it: use the documented APP_FEATUREENABLED form, and verify the effective value on the running application rather than reasoning from memory. If the team finds APP_FEATUREENABLED hard to read, a cleaner long-term fix is to rename the property to app.feature.enabled, so the natural variable name matches.
3Is the Variable Really in the Process?
A variable in a deployment file is not necessarily a variable in the JVM. The manifest may not have been applied, the pod may not have been restarted, an entrypoint script may start Java with a cleaned environment, or the variable may be set on the wrong container in the pod. So we check the process itself. In Kubernetes, kubectl exec into the container and run env, or read /proc/1/environ for the Java process, assuming it is process 1. Environment variables are read once at process start, so changing a ConfigMap does not change the environment of a running JVM; only a restart does.
4Asking the Application Which Source Won
Once we know the variable is present, we ask Spring which property source supplied the value. The actuator env endpoint for a single key lists every source that has it, in priority order, with the effective value.
The output above is shortened and illustrative, but the useful parts are the source of the winning value and whether systemEnvironment has an entry at all. If systemEnvironment has no entry for the key, the name does not map. The configprops endpoint shows the bound values of @ConfigurationProperties beans with their origin, which helps when the code reads the value through a properties class. Both endpoints expose configuration, so they must be secured, and since Spring Boot 3 they mask values unless show-values is set to when-authorized for an authorised role.
5Looking for a Higher-Priority Source
If the variable maps correctly and is present, something above it may be winning. Command-line arguments such as --app.feature-enabled=false in the container's args, Java system properties in JAVA_TOOL_OPTIONS or JAVA_OPTS, and SPRING_APPLICATION_JSON all beat environment variables. A config server or another imported source can also be placed above them depending on how it is configured. The env endpoint's list makes all of these visible at once, which is why it is the second thing to look at, not the last.
- Does the name map to the key?YesContinueNoFix the variable name or rename the property
- Is the variable in the running process?YesContinueNoFix the deployment and restart
- Which source wins in /actuator/env?YesRemove or change the higher sourceNoCheck how the code reads the value
3 steps in order. Play them, or step through them one at a time.
6How the Code Reads the Value Matters
The last step is to look at the code. With @ConfigurationProperties, binding is fully relaxed, so every supported spelling of the name binds. With @Value("${app.feature-enabled}"), relaxed matching is limited, and the Spring Boot documentation recommends always writing the key in kebab-case there. A @Value written as ${app.featureEnabled} or ${APP_FEATURE_ENABLED} may behave differently from what we expect. Reading the value with environment.getProperty in a test, with the exact variable set, removes the guesswork for our version.
7Follow-up questions
Why does Spring Boot remove dashes instead of turning them into underscores?
Because underscores already mean dots, the separator between groups. If dashes also became underscores, APP_FEATURE_ENABLED could mean either app.feature-enabled or app.feature.enabled, and the mapping would be ambiguous. Removing dashes keeps the mapping from property name to variable name unique.
How do I set a list value through an environment variable?
Use the index in the name: APP_SERVERS_0_HOST and APP_SERVERS_1_HOST bind to app.servers[0].host and app.servers[1].host. For a simple list of strings, a comma-separated value in APP_SERVERS also works, because Boot converts comma-separated text to a list.
Is it safe to expose the env endpoint in production?
Only with care. It reveals configuration, so it should be on a management port or path that is not public, require an authenticated operations role, and keep value masking on for everyone else. Many teams enable it only temporarily or use configprops for the specific properties classes they need.
8Conclusion
In this answer, we investigated an environment variable that did not override application.yml. The first suspect was the name: by the documented rule app.feature-enabled maps to APP_FEATUREENABLED, while APP_FEATURE_ENABLED names app.feature.enabled, and any legacy fallback varies by version. Then we checked that the variable exists in the running process, used the secured env and configprops endpoints to see which source won, looked for higher-priority sources such as command-line arguments, and remembered that @Value has only limited relaxed binding.
Open with
My first suspect is the name. Spring Boot maps a property to an environment variable by replacing dots with underscores, removing dashes and upper-casing, so app.feature-enabled maps to APP_FEATUREENABLED.
Then, if they want more
An underscore means a dot, so APP_FEATURE_ENABLED is really app.feature.enabled, a different property. Some versions have a legacy fallback that might accept it, which is why I would not rely on memory and would verify on the running app.
Second, I check that the variable is actually in the process, not only in the manifest: exec into the container and look at env or proc environ, and remember that a running JVM never sees a changed ConfigMap until it restarts.
Third, I ask the application: the actuator env endpoint for that key shows every property source that has it and which one won, and configprops shows the bound value with its origin. Those endpoints must be secured and show values only to authorised users.
If systemEnvironment has no entry, the name is wrong; if a command-line argument, JAVA_TOOL_OPTIONS system property or config server wins, I fix that source. Finally I look at how the code reads it: ConfigurationProperties is fully relaxed, but Value only has limited relaxed binding, so keys should be in kebab-case there.
Longer term I might rename the property to app.feature.enabled so the obvious variable name works.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Boot 3
- 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 "An environment variable APP_FEATURE_ENABLED=true does not override...": https://scrivio-interview-library.netlify.app/spring-boot/spring-configuration/2cbb866b3c/