Performance: Configuration precedence order
This affects application startup time and runtime configuration loading speed.
Use Spring Boot's default configuration precedence:
1. Command line args
2. Java System properties
3. OS environment variables
4. Profile-specific config files
5. application.properties or application.yml in src/main/resources
6. Custom config files loaded last if neededapplication.properties in src/main/resources application.yml in src/main/resources Command line args Environment variables Custom config files loaded manually in code
| Pattern | Config Sources Loaded | Parsing Overhead | Startup Delay | Verdict |
|---|---|---|---|---|
| Manual unordered loading | Many redundant | High repeated parsing | 300ms+ blocking | [X] Bad |
| Spring Boot default order | Minimal necessary | Single parse per source | 100ms blocking | [OK] Good |
application.properties file?application.properties files, like server.port=8080.application.properties sets server.port=8080SERVER_PORT=9090--server.port=7070server.port=8080 in application.properties and also pass --server.port=9090 as a command line argument, but the app still runs on port 8080. What is the most likely cause?app.mode=dev in your Spring Boot app but allow it to be overridden by environment variables or command line arguments. Which order of precedence correctly applies?Pass the test and this pattern moves unknown