Which of the following files is used to configure application properties in a Spring Boot project?
Answer:
Explanation:
The application.properties
file is used to configure application properties in a Spring Boot project. This file allows developers to specify various configuration settings, such as server ports, database connection details, logging levels, and other application-specific properties. The application.properties
file is typically located in the src/main/resources
directory of a Spring Boot project.
For example, you can set the server port and database connection details in the application.properties
file:
# Server settings
server.port=8080
# Database settings
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=root
spring.datasource.password=secret
Spring Boot also supports configuration in YAML format, using the application.yml
file. The choice between application.properties
and application.yml
is a matter of preference, with YAML offering a more structured and hierarchical format.
The application.properties
file is a key component of the Spring Boot auto-configuration mechanism, allowing developers to customize the behavior of their applications without modifying the code. It also supports profile-specific configurations, where different settings can be applied based on the active environment (e.g., development, testing, production).