Spring Boot resolves configuration properties from multiple sources using a defined order of precedence, so the same property can be safely overridden differently across environments.
If application.yml sets server.port: 8080 but the container starts the app with java -jar app.jar --server.port=9090, the application runs on port 9090, because command-line arguments take priority over file-based configuration.
# application.yml inside the JAR
server:
port: 8080
# Higher sources override lower ones (simplified, highest first):
# 1. Command-line arguments
java -jar app.jar --server.port=9090 # -> 9090 wins
# 2. JVM system properties
java -Dserver.port=8500 -jar app.jar
# 3. OS environment variables (relaxed binding: SERVER_PORT -> server.port)
SERVER_PORT=8200 java -jar app.jar
# 4. Config files: files outside the JAR (e.g. ./config/) beat the ones
# packaged inside it, and at the same location application-prod.yml
# beats application.yml
# See which value won and where it came from
curl localhost:8080/actuator/env/server.portA concise interview answer is
Command-line arguments win first, then environment variables and system properties, then profile-specific files like application-prod.yml, then the base application.yml, and finally Spring Boot's own defaults. That hierarchy is exactly what lets the same build run correctly in different environments just by overriding values at the right level.
Last updated: 1 November 2026
Previous question: How can Actuator be used for application monitoring and management?
Next question: Can you deploy a Spring Boot application as a traditional WAR file to an external server?