0
0
Spring Bootframework~10 mins

application.yml alternative in Spring Boot - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - application.yml alternative
Start Spring Boot App
Check for application.yml
No
Check for application.properties
Yes
Load properties from application.properties
Use loaded properties in app
Run
Spring Boot first looks for application.yml. If not found, it checks for application.properties and loads it to configure the app.
Execution Sample
Spring Boot
server.port=8081
spring.datasource.url=jdbc:mysql://localhost:3306/db
logging.level.root=INFO
This application.properties file sets server port, database URL, and logging level as an alternative to application.yml.
Execution Table
StepFile CheckedFound?ActionResult
1application.ymlNoSkip to next config fileNo YAML config loaded
2application.propertiesYesLoad propertiesProperties loaded into environment
3Use propertiesN/AConfigure app with loaded propertiesServer port=8081, DB URL set, Logging=INFO
4Start appN/ARun with configured settingsApp runs on port 8081 with given configs
💡 application.yml not found, application.properties found and loaded, app configured and started
Variable Tracker
VariableStartAfter Step 2After Step 3Final
server.portdefault 8080808180818081
spring.datasource.urlnonejdbc:mysql://localhost:3306/dbjdbc:mysql://localhost:3306/dbjdbc:mysql://localhost:3306/db
logging.level.rootdefault INFOINFOINFOINFO
Key Moments - 2 Insights
Why does Spring Boot use application.properties when application.yml is missing?
Spring Boot checks for application.yml first. If it doesn't find it (see execution_table step 1), it looks for application.properties and loads it instead (step 2).
Can I use application.properties and application.yml together?
Yes, but application.yml has higher priority. If both exist, Spring Boot loads application.yml first and overrides properties from application.properties.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step does Spring Boot load the alternative config file?
AStep 3
BStep 1
CStep 2
DStep 4
💡 Hint
Check the 'Action' column for when properties are loaded.
According to variable_tracker, what is the final value of server.port?
A8080
B8081
Cdefault
Dnone
💡 Hint
Look at the 'Final' column for server.port.
If application.yml existed, how would the execution_table change?
AStep 1 would find application.yml and load it, skipping application.properties
BStep 2 would still load application.properties
CBoth files would load simultaneously
DApp would fail to start
💡 Hint
Refer to concept_flow showing priority order.
Concept Snapshot
Spring Boot config files order:
1. application.yml (preferred)
2. application.properties (alternative)
If application.yml missing, properties file loads.
Properties set here configure app behavior like port, DB, logging.
Use either file format but YAML has priority.
Full Transcript
Spring Boot applications look for configuration files to set up app settings. The preferred file is application.yml. If this file is missing, Spring Boot checks for application.properties as an alternative. When application.properties is found, Spring Boot loads its key-value pairs to configure the app, such as server port, database connection, and logging levels. This process ensures the app runs with the desired settings. If both files exist, application.yml takes priority and overrides properties from application.properties. This behavior helps developers choose their preferred config format while maintaining a clear loading order.