Spring Boot Configuration Priority: A Tiny Detail That Wastes Hours
Understanding Spring Boot's config priority order saves you from debugging hell and late nights.

Ever changed a property in application.yml, fired up your app, and watched it completely ignore your change? Welcome to the club. Spring Boot has a strict hierarchy of configuration sources, and not knowing it is a one-way ticket to debugging purgatory.
How It Works (and Backfires)
Spring Boot applies settings in a precise order: higher priority wins. The hierarchy from highest to lowest:
- Command-line arguments (e.g.,
--server.port=9090) - JNDI attributes (archaic but present)
- JVM system properties (via
-D) - OS environment variables (DevOps' favorite)
application-{profile}.properties/yml(profile-specific)application.properties/yml(the default)@PropertySourceon config classes (if you're into that)- Default values (via
@Valuewith defaults)
Classic pain point: you tweak application.yml, but SERVER_PORT env var is set on the server — your app stubbornly listens on 8080 instead of 9090. Or a colleague passed a command-line arg in Docker, and you spend half a day hunting down the rogue value.
Where the Trap Lies
The real killer is forgetting about higher-priority sources. Environment variables are especially sneaky — they can be set by the system, CI/CD, or just linger in a terminal session. Another gotcha: profiles. If you launch with spring.profiles.active=prod, application-prod.yml overrides common settings but still bows to command-line args.
How to Keep Your Sanity
- Always check active sources via Actuator:
/actuator/envshows all values and their origin. - Use prefixes like
--spring.config.additional-locationto explicitly point to files. - Don't rely on magic: if behavior seems off, start by checking environment variables and launch arguments.
METABYTE studio comment: We've all been there — your app ignoring config like a teenager ignoring chores. Our devs always double-check the priority chain so you don't lose sleep over a phantom server.port. And if you want to automate config management, we can make that painless too.
NEXT STEP
Liked the approach?
We apply the same principles to client projects: AI, automation, products that don't die after launch.