Turns on detailed logging for Spring framework classes.
Spring Boot
logging.level.org.springframework=DEBUG
Custom flag to enable a feature in your app.
Spring Boot
app.featureX.enabled=true
Sample Program
This application.properties file sets the server port to 9090, configures an in-memory H2 database, sets logging level to INFO, and defines a welcome message.
Spring Boot
# application.properties
server.port=9090
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.username=sa
spring.datasource.password=
logging.level.root=INFO
app.welcome.message=Hello from Spring Boot!
OutputSuccess
Important Notes
Lines starting with # are comments and ignored.
Use consistent naming with dots to keep settings organized.
Changes to application.properties usually require restarting the app to take effect.
Summary
application.properties stores app settings as key=value pairs.
Use dots in keys to group related settings.
This file helps configure your app without changing code.
Practice
(1/5)
1. What is the primary purpose of the application.properties file in a Spring Boot project?
easy
A. To store configuration settings as key=value pairs
B. To write Java code for the application
C. To define database tables
D. To create HTML templates
Solution
Step 1: Understand the role of application.properties
This file is used to hold configuration settings for the Spring Boot app.
Step 2: Identify the format and purpose
It stores settings as simple key=value pairs to configure app behavior without code changes.
Final Answer:
To store configuration settings as key=value pairs -> Option A
Quick Check:
Config file = key=value pairs [OK]
Hint: Remember: properties file = settings in key=value form [OK]
Common Mistakes:
Confusing properties file with source code files
Thinking it stores HTML or database schema
Assuming it runs application logic
2. Which of the following is the canonical syntax to set the server port to 8081 in application.properties?
easy
A. server-port=8081
B. server_port=8081
C. server.port=8081
D. serverPort=8081
Solution
Step 1: Recall the key naming convention
Spring Boot uses dot notation to group related settings, so keys use dots, not dashes or underscores.
Step 2: Match the correct syntax
The correct key for server port is server.port, followed by = and the port number.
Final Answer:
server.port=8081 -> Option C
Quick Check:
Dots separate groups in keys = correct syntax [OK]
Hint: Use dots, not dashes or underscores in keys [OK]