Scrivio Interview library
ScenarioIntermediate6 min read · updated 12 November 2026

A Spring Boot service has 14 .properties files across profiles and environments, and production behaviour differs from staging because of an unexpected override. How do you find which value wins and simplify the setup?

We let Spring Boot tell us: the secured actuator env endpoint, for example /actuator/env/payment.timeout, lists every property source that defines the key, in priority order, with the winning value and the exact file and line it came from. Knowing Boot's order, command-line arguments and environment variables above profile files above application.properties, explains why. Then we simplify: fewer files, environment-specific values in environment variables or a config server, typed and validated @ConfigurationProperties, and a startup test per profile.

Why this question is asked

Configuration drift is one of the most common causes of "works in staging, fails in production". With 14 properties files, profiles, environment variables in a deployment manifest and possibly a config server, nobody can say by reading which value wins, and guessing wastes hours during an incident. Interviewers ask this scenario because the answer shows whether we know Spring Boot's property source order and its diagnostic tools, and whether we fix the setup rather than just the one value. In this answer, we will recap how Boot builds its Environment, find the winning value and its origin with the actuator, walk through the order that decides it, look at the usual culprits, and then simplify the setup and protect it with validation and tests.

1A Quick Recap: Property Sources and the Environment

Spring Boot does not read one configuration file. It builds an Environment from a list of property sources: command-line arguments, Java system properties, operating system environment variables, application.properties and application-{profile}.properties inside the jar and outside it, a config server if one is configured, and others. When code asks for payment.timeout, Boot walks the list from the highest priority down and returns the first value it finds. The others still exist; they are just hidden.

Boot also uses relaxed binding, so the environment variable PAYMENT_TIMEOUT supplies payment.timeout. That is convenient, and it is also how a forgotten variable in a production Kubernetes manifest overrides a value that everyone believes comes from a file.

2Finding Which Value Wins and Where It Came From

The actuator env endpoint answers the question directly. It is sensitive, so in production we expose it only on the management port, behind authentication, and show values only to authorised users; since Spring Boot 3, values are masked by default.

Java
# management settings (production: separate port, secured)
management.server.port=9090
management.endpoints.web.exposure.include=health,env,configprops
management.endpoint.env.show-values=when-authorized
$ curl -u ops:*** http://pod:9090/actuator/env/payment.timeout
{
"property": { "source": "systemEnvironment", "value": "5s" }, <- the winner
"propertySources": [
{ "name": "systemEnvironment", "property": { "value": "5s", "origin": "System Environment Property \"PAYMENT_TIMEOUT\"" } },
{ "name": "Config resource 'class path resource [application-prod.properties]'",
"property": { "value": "30s", "origin": "class path resource [application-prod.properties] - 12:17" } },
{ "name": "Config resource 'class path resource [application.properties]'",
"property": { "value": "10s", "origin": "class path resource [application.properties] - 4:17" } }
]
}

Notice that it shows every source that defines the key, in priority order, with the origin down to file, line and column. Here the mystery is solved in one call: a PAYMENT_TIMEOUT environment variable wins over the 30s everyone expected from application-prod.properties. The /actuator/configprops endpoint shows the same for @ConfigurationProperties beans, grouped by prefix. The output shape differs a little between versions, so check yours.

Running with --debug is often suggested, but it prints the auto-configuration condition report, which explains which beans were created, not where a property value came from. When the actuator is not available, a small runner that walks the property sources for a few named keys gives the same answer in the startup log; we just make sure it never prints secrets.

3The Order That Decides It

The full list is long, but a handful of sources cause nearly every surprise. From highest to lowest priority, the ones that matter here are shown below. Within the config files, a later profile in spring.profiles.active beats an earlier one, and a file outside the jar beats the same file inside it.

Common property sources, highest priority first
PrioritySourceTypical surprise
1Command-line arguments (--key=value)a flag left in a start script
2SPRING_APPLICATION_JSONa JSON blob in a container definition
3Java system properties (-Dkey=value)JAVA_OPTS set by the platform
4OS environment variablesa leftover variable in a manifest
5application-{profile} outside the jar./config/ on one server only
6application.properties outside the jaran old file next to the jar
7application-{profile} inside the jarthe value we expected
8application.properties inside the jarthe default
A simplified view; config server, test properties and others also take part. Check the Boot reference for your version.

Production and staging usually differ in exactly these upper layers: different manifests, different start scripts, a config directory on one set of machines. That is why the jar can be identical and the behaviour still differ.

4The Usual Culprits

Once we have the origin, the cause is usually one of a few things. An environment variable or -D option defined in the production deployment and not in staging, often added during an old incident. An external config/application.properties left on production hosts. Profiles that differ, for example production activating prod,eu while staging activates prod, so application-eu.properties overrides values only in production. A file pulled in by spring.config.import, or a multi-document file with a spring.config.activate.on-profile section that nobody remembered. With 14 files, it is usually not one mistake but the sheer number of places a value can hide.

5Simplifying the Setup

The goal is that a person can predict the effective configuration. I would collapse the 14 files into one application.properties with safe defaults plus at most one file per real profile, and pick one format, properties or YAML, for the whole service. Values that differ per environment, URLs, pool sizes, timeouts, move out of files into environment variables in the deployment manifests or into a config server, so each environment's configuration lives in one reviewed place. Secrets come from a secrets manager, never from files in the jar.

Then we bind configuration to typed, validated classes, so a missing or nonsense value stops the application at startup instead of misbehaving at runtime.

Java
@ConfigurationProperties(prefix = "payment")
@Validated
public record PaymentProperties(
@NotNull @DurationMin(seconds = 1) @DurationMax(seconds = 60) Duration timeout,
@NotBlank String gatewayUrl,
@Min(1) @Max(200) int maxConnections) {}
// payment.timeout=0s -> the application fails to start with a binding validation error
// that names payment.timeout and the violated constraint

6Protecting It With a Startup Test per Profile

Finally, a fast test loads the configuration for each profile and asserts the values that matter. ApplicationContextRunner, or a slim @SpringBootTest, does this without starting the whole service. If someone adds an override that changes the production timeout, the test fails in the pull request instead of in production.

Java
@SpringBootTest(classes = PaymentConfig.class)
@ActiveProfiles("prod")
class ProdConfigTest {
@Autowired PaymentProperties payment;
@Test
void prodTimeoutIsThirtySeconds() {
assertThat(payment.timeout()).isEqualTo(Duration.ofSeconds(30)); // passes only if nothing overrides it
}
}

The test only sees files, not the production environment variables, so it pairs with a review rule for manifests, and with the actuator check after each deployment for the few keys that matter most.

7Follow-up questions

Should we expose /actuator/env in production at all?

Yes, but carefully: on a separate management port not reachable from the internet, behind authentication, with show-values set to when-authorized or never, and keys like passwords sanitised. During an incident it saves far more time than it costs to secure.

Properties or YAML?

Either works; mixing them is the problem, because both can define the same key and the precedence between them is easy to forget. Pick one per service, and per organisation if possible.

How do profiles interact when several are active?

Profile files are applied in the order the profiles are listed, and later ones win. So with spring.profiles.active=prod,eu, a key in application-eu.properties overrides the same key in application-prod.properties.

8Conclusion

In this answer, we saw that Spring Boot builds its Environment from an ordered list of property sources and returns the first value it finds. The secured actuator env endpoint shows every source of a key with its origin, which answers which value wins, while --debug only shows the auto-configuration report. Knowing the order, command-line and environment above profile files above defaults, explains the override. We then simplified to a few files, moved environment-specific values to manifests or a config server, validated typed @ConfigurationProperties, and added a startup test per profile.

What to say in the interviewAbout 80 seconds aloud

Open with

First I would stop guessing and ask Spring Boot. The actuator env endpoint, secured on the management port with show-values set to when-authorized, lets me request a single key, and it lists every property source that defines it, in priority order, with the value and the exact origin, file and line, or the environment variable name. configprops shows the same for ConfigurationProperties beans.

Then, if they want more

Debug mode is sometimes suggested, but that prints the auto-configuration report, not property origins. The order explains the result: command-line arguments and system properties beat environment variables, which beat profile-specific files, which beat application.properties, and files outside the jar beat files inside it, with later active profiles winning.

Typical culprits are an environment variable in the production manifest, which relaxed binding maps onto the key, an external config folder on prod hosts, or an extra active profile.

Then I would simplify: one application.properties with defaults and at most one file per real profile, one format, environment-specific values in manifests or a config server, and secrets from a secrets manager.

I would bind to validated ConfigurationProperties records so wrong or missing values fail at startup, and add a test per profile that asserts the important values, so the next accidental override fails in CI.

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.
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 "A Spring Boot service has 14 .properties files across profiles and environments, and...": https://scrivio-interview-library.netlify.app/java/io-and-nio/fc85440333/