What is the purpose of the application.properties file in a Spring Boot project?
It is used to configure application settings like server port, database connection, and other properties in a simple key-value format.
Click to reveal answer
beginner
How are properties structured inside application.properties?
Properties are written as key-value pairs separated by an equals sign, for example: server.port=8080
Click to reveal answer
intermediate
How can you organize properties for different environments using application.properties?
You create separate files like application-dev.properties or application-prod.properties and activate them via the spring.profiles.active property.
Click to reveal answer
intermediate
What is the difference between application.properties and application.yml?
application.properties uses simple key-value pairs, while application.yml uses YAML format which supports nested structures and is more readable for complex configs.
Click to reveal answer
beginner
Can you use comments in application.properties? How?
Yes, comments start with a hash symbol #. Anything after # on the line is ignored by Spring Boot.
Click to reveal answer
What symbol separates keys and values in application.properties?
A,
B:
C-
D=
✗ Incorrect
In application.properties, keys and values are separated by an equals sign =.
How do you activate a specific profile in Spring Boot?
Aspring.profiles.active=profileName
Bprofile.active=spring
Cspring.active.profile=profileName
Dactive.profile=spring
✗ Incorrect
You set spring.profiles.active=profileName in application.properties to activate a profile.
Which file format supports nested configuration better?
Aapplication.yml
Bapplication.xml
Capplication.properties
Dapplication.json
✗ Incorrect
application.yml supports nested structures better than application.properties.
How do you write a comment in application.properties?
A// This is a comment
B<!-- This is a comment -->
C# This is a comment
D/* This is a comment */
✗ Incorrect
Comments start with # in application.properties.
What would this line do? server.port=9090
ASets the database port to 9090
BSets the server port to 9090
CStarts the server on port 80
DDisables the server
✗ Incorrect
This sets the Spring Boot server to listen on port 9090.
Explain the structure and purpose of the application.properties file in Spring Boot.
Think about how you tell your app what settings to use.
You got /4 concepts.
Describe how to manage different environments using application.properties files.
Consider how you might have different settings for testing and production.
You got /3 concepts.
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]