0
0
Spring Bootframework~5 mins

Application.properties basics in Spring Boot - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
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 do you set the server port to 8081 in application.properties?
Add the line server.port=8081 to the application.properties file.
Click to reveal answer
beginner
Can you use application.properties to configure database connection details? Give an example.
Yes. For example:<br>spring.datasource.url=jdbc:mysql://localhost:3306/mydb<br>spring.datasource.username=root<br>spring.datasource.password=secret
Click to reveal answer
intermediate
What happens if you have conflicting properties in application.properties and application.yml?
Spring Boot uses a priority order. Usually, application.properties and application.yml are merged, but if the same property is defined in both, the last one loaded wins. It's best to avoid conflicts.
Click to reveal answer
intermediate
How can you access a property defined in application.properties inside your Spring Boot Java code?
You can use the @Value annotation, for example:<br>@Value("${property.name}")<br>private String propertyName;
Click to reveal answer
Which file format is used for application.properties?
AJSON format
BXML format
CKey-value pairs separated by '='
DYAML format
How do you change the default server port in Spring Boot using application.properties?
Aserver.port=8081
Bport=8080
Cserver.port=8080
DserverPort=8081
Which annotation allows you to inject a property value from application.properties into a Spring Boot component?
A@Autowired
B@PropertySource
C@Component
D@Value
If you want to set a database URL in application.properties, which prefix is commonly used?
Aspring.datasource.
Bdatabase.url.
Cdb.connection.
Dspring.db.url.
What is the file name for the default Spring Boot configuration file using properties format?
Aapplication.yaml
Bapplication.properties
Cconfig.properties
Dspring.properties
Explain how to configure the server port and database connection in application.properties.
Think about key-value pairs for server and database settings.
You got /4 concepts.
    Describe how to access a property from application.properties inside a Spring Boot Java class.
    Consider how Spring Boot injects configuration values.
    You got /3 concepts.