Card 01/ 06
All 6 cards
ConceptDifficulty: Intermediate1 min
Where a Property Can Come From
server.port can be set in application.properties, in an environment variable, or passed on the command line — and a real deployment usually sets it in more than one of these at once, for different reasons: a sensible default in the file, an override for one environment.
Spring Boot reads from all of them and needs a fixed order to resolve a conflict. From lowest to highest priority, the ones worth knowing: application.properties on the classpath, a profile-specific file such as application-prod.properties, an OS environment variable, and a command-line argument — each one able to override everything before it.
"Command-line wins" is the one worth holding onto by itself: whatever a file says, --server.port=9090 on the command line is the value the application actually uses.