Free tools Windows power users keep installed
One-click scans. No signup required.
Spring Boot builds an Environment from configuration sources, resolves duplicate keys by precedence, then makes the winning values available to your application. That is why a value written in application.yaml is not necessarily the value your app uses at runtime: a profile-specific file, environment variable, Java system property, or command-line argument may take precedence.
The details below follow the Spring Boot 3.4.13 reference. Check the documentation for the version your application runs, since the Spring documentation identifies 4.1.1 as the latest stable release.
How Spring Boot configuration works
Configuration handling has three linked parts: Boot loads potential values from sources, precedence rules decide which value wins when keys conflict, and application code reads or binds the effective values. Spring describes the goal as letting you use “the same application code in different environments.” Spring Boot 3.4 Externalized Configuration reference
Values can come from config files as well as sources such as operating-system environment variables, Java system properties, JSON configuration, command-line arguments, and test-specific sources. You can look values up through the Environment, inject one value with @Value, or bind a group of related values with @ConfigurationProperties.
#1 Best Overall
Which configuration property wins?
Spring Boot applies an ordered set of property sources. In the Spring Boot 3.4 reference, config data is followed by operating-system environment variables, Java system properties, JNDI and servlet sources, SPRING_APPLICATION_JSON, and command-line arguments. Test sources and Devtools settings appear higher in the documented order. A higher-priority source can override a lower-priority one.
This is why a file alone may not explain the runtime value. For example, a launch argument such as --server.port=9000 becomes an Environment property by default and can override a file-based port. Applications can disable command-line properties with SpringApplication.setAddCommandLineProperties(false).
Rank #2
How config files and profiles affect precedence
Packaged and external config data
Within config data, the documented order considers packaged base files before packaged profile-specific files, then external base files, then external profile-specific files. Consequently, an external profile-specific value can take precedence over one in a packaged file. If both .properties and YAML files exist at the same location, the Spring Boot 3.4 reference says .properties takes precedence.
There is no general rule that YAML always overrides properties, or vice versa. The result depends on file location, whether a file is profile-specific, the active profiles, and higher-priority property sources.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Rank #3
Active profiles
spring.profiles.active selects profiles. If none is active, Boot uses the default profile unless that default has been changed. Profile-specific files apply when their profile is active. If multiple profiles are active, later profiles can override earlier ones. The Spring Boot 3.4 Profiles reference also documents @Profile for limiting which components or configuration-properties beans are available under particular profiles.
Imports and file-search locations
spring.config.import adds config data to the set Boot loads; values from an imported file can override values in the document that declares the import. spring.config.location changes where Boot searches, while spring.config.name changes the name it searches for. A required location that is missing can prevent startup. Prefixing an import with optional: allows that imported location to be absent.
Rank #4
How application code consumes the resolved values
Environment: use programmatic lookup when code needs to query a property.@Value: inject an individual property into a field, constructor parameter, or method parameter.@ConfigurationProperties: bind related properties to a structured object. Spring recommends this approach for a component’s own group of configuration keys; it supports relaxed binding and configuration metadata.
These mechanisms consume configuration; they do not determine which source has priority. First establish the effective value through source precedence, then consider how the application binds or reads it.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How to trace an unexpected value
- Check the launch context. Review command-line arguments and environment variables, since both can supersede file values.
- Confirm active profiles. Check
spring.profiles.active, whether the default profile applies, and the order of multiple active profiles. - Identify the config files Boot loads. Compare packaged and external files, base and profile-specific variants, imports, and any changed search location or config name. If formats coexist at one location, account for
.propertiestaking precedence over YAML in the documented 3.4 behavior. - Check the read or binding point. Confirm the property name and whether the code uses
Environment,@Value, or@ConfigurationProperties.
This sequence is a practical way to diagnose a mismatch, not a description of an exact human-readable sequence Boot follows internally.
Use documentation for the Boot version you run
The precedence details in this article are from Spring Boot 3.4.13’s reference, while Spring’s documentation page identifies 4.1.1 as the latest stable release. Do not assume every detail is identical across versions; use the reference corresponding to your application’s Boot version.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




