| Priority | Source | Example / Notes |
|---|---|---|
| 1 | Command-line arguments | e.g. --my.property=value when running the application |
| 2 | Java System properties | e.g. -Dmy.property=value |
| 3 | OS environment variables | e.g. export MY_PROPERTY=value |
| 4 | Application properties or YAML files | Located in src/main/resources/application.properties or .yml |
| 5 | Profile-specific configuration files | e.g. application-dev.properties when spring.profiles.active=dev |
| 6 | External configuration files | Files located in a /config directory outside the packaged JAR |
| 7 | JNDI attributes | Used in servlet containers or enterprise environments |
| 8 | Random values | e.g. ${random.uuid}, ${random.int} generated by Spring Boot |
| 9 | Default value in code | The fallback provided in @Value("${my.property:default}") |
Created
November 20, 2025 15:37
-
-
Save ashutoshkrris/fbc43172d0c9885b2262378ff75ce59f to your computer and use it in GitHub Desktop.
This Gist shows the priority order of how the @value annotation in Spring Boot works when injecting configuration values. The list is organized from the highest to lowest priority, covering sources like command-line arguments, system properties, environment variables, application property files, and more. Understanding this order is crucial for …
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment