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=secretClick 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?✗ Incorrect
application.properties uses simple key-value pairs separated by '='.How do you change the default server port in Spring Boot using
application.properties?✗ Incorrect
The correct property to change the port is
server.port.Which annotation allows you to inject a property value from
application.properties into a Spring Boot component?✗ Incorrect
@Value is used to inject property values.If you want to set a database URL in
application.properties, which prefix is commonly used?✗ Incorrect
Spring Boot uses
spring.datasource. prefix for database settings.What is the file name for the default Spring Boot configuration file using properties format?
✗ Incorrect
The default configuration file is
application.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.