Dive deep into the world of Spring Boot with a focus on properties and configuration. Spring Boot offers an elegant solution to the age-old problem of configuration management in large applications. Through the use of properties, developers can control various aspects of an application without diving into the codebase.
Whether you're just starting out with Spring Boot or want to brush up on your knowledge, this MCQ guide centered around Spring Boot Properties & Configuration is your go-to resource. Let's get started!
1. Which file is primarily used to define properties in a Spring Boot application?
Answer:
Explanation:
In a Spring Boot application, application.properties is the primary file to define configuration properties.
2. If you want to use YAML instead of properties for configuration in Spring Boot, which file would you create?
Answer:
Explanation:
Spring Boot supports YAML for configuration, and the file name used is application.yaml.
3. How can you access properties defined in application.properties in your Java class?
Answer:
Explanation:
The @Value annotation is used to inject property values from application.properties into Java classes.
4. Which annotation enables type-safe property binding in Spring Boot?
Answer:
Explanation:
The @ConfigurationProperties annotation enables type-safe property binding in Spring Boot.
5. Which of the following properties will set the application's logging level to DEBUG for all packages?
Answer:
Explanation:
The logging.level.root property sets the logging level for all packages in the application.
6. What is the default properties file name for profile-specific configurations in Spring Boot?
Answer:
Explanation:
For profile-specific configurations, the default file name pattern is application-<profile>.properties.
7. How can you specify active profiles for your Spring Boot application?
Answer:
Explanation:
The spring.profiles.active property allows specifying which profiles are currently active.
8. In Spring Boot, where does the @PropertySource annotation look for properties files by default?
Answer:
Explanation:
By default, the @PropertySource annotation looks for properties files at the classpath root.
9. If both application.properties and application.yaml are present, which one takes precedence?
Answer:
Explanation:
If both files are present, properties from the file that is loaded last will take precedence.
10. Which property helps specify external configuration directories for Spring Boot?
Answer:
Explanation:
The spring.config.location property specifies external directories for Spring Boot configuration.
11. What does the spring.main.banner-mode property control?
Answer:
Explanation:
The spring.main.banner-mode property controls the appearance and behavior of the Spring Boot banner during application startup.
12. What will the property spring.datasource.initialize set to false do?
Answer:
Explanation:
Setting spring.datasource.initialize to false will prevent Spring Boot from automatically initializing the database using the data.sql script.
Related Spring Boot MCQ Posts
- Spring Boot Starters MCQ - Multiple Choice Questions and Answers
- Spring Boot Auto Configurations MCQ - Multiple Choice Questions and Answers
- Spring Boot Properties & Configuration MCQ - Multiple Choice Questions and Answers
- Spring Boot Data Access MCQ - Multiple Choice Questions and Answers
- Spring Boot Actuator MCQ - Multiple Choice Questions and Answers
- Spring Boot Security MCQ - Multiple Choice Questions and Answers
- Spring Boot Testing MCQ - Multiple Choice Questions and Answers
- Spring Boot Microservices MCQ - Multiple Choice Questions and Answers
Comments
Post a Comment
Leave Comment