Spring Boot: Customizing Auto-Configuration Essentials
A beginner's quiz on customizing auto-configuration in Spring Boot applications.
Questions in this quiz
15 questions on Spring Boot: Customizing Auto-Configuration Essentials. Work through them here, then start the quiz to answer them and see your score.
1.What is the primary purpose of Spring Boot's auto-configuration feature?
- ATo provide a graphical user interface for configuration
- BTo automatically configure a Spring application based on the dependencies present on the classpath
- CTo manually configure all beans in a Spring application
- DTo disable all configurations in a Spring application
2.Which annotation is used to exclude a specific auto-configuration class in Spring Boot?
- A@ComponentScan
- B@EnableAutoConfiguration
- C@ExcludeAutoConfiguration
- D@SpringBootApplication
3.How can you customize a bean that is automatically configured by Spring Boot?
- ABy disabling Spring Boot auto-configuration
- BBy defining a bean with the same name and type in your configuration
- CBy modifying the Spring Boot source code
- DBy using a different framework
4.Which property can be used to disable all auto-configuration in application.properties?
- Aspring.autoconfigure.disable
- Bspring.autoconfigure.exclude
- Cspring.main.web-application-type
- Dspring.autoconfigure.enable
5.What is the role of the @ConditionalOnMissingBean annotation in Spring Boot?
- AIt deletes a bean from the context
- BIt ensures a bean is only created if another bean is missing
- CIt ensures a bean is always created
- DIt disables a bean if another bean is present
6.Which of the following is a common use case for customizing auto-configuration?
- ATo increase application size
- BTo make the application slower
- CTo remove all configurations
- DTo optimize performance by loading only necessary configurations
7.What does the @SpringBootApplication annotation do?
- AIt only configures beans
- BIt combines @Configuration, @EnableAutoConfiguration, and @ComponentScan
- CIt only enables component scanning
- DIt disables auto-configuration
8.How can you view which auto-configuration classes are being applied in a Spring Boot application?
- ABy using a debugger
- BBy enabling debug logging for org.springframework.boot.autoconfigure
- CBy checking the application.properties file
- DBy running the application in production mode
9.Which annotation would you use to conditionally apply configuration based on the presence of a specific class?
- A@ConditionalOnBean
- B@ConditionalOnMissingClass
- C@ConditionalOnMissingBean
- D@ConditionalOnClass
10.What is the default behavior of Spring Boot if a configuration class is not explicitly defined?
- AIt throws an error
- BIt stops the application
- CIt uses auto-configuration to set up the application context
- DIt does nothing
11.Which annotation is used to exclude a specific configuration class from being applied?
- A@Component
- B@Service
- C@EnableAutoConfiguration(exclude = ...)
- D@Configuration
12.What is the purpose of the spring.factories file in Spring Boot?
- ATo list auto-configuration classes
- BTo configure database connections
- CTo store application properties
- DTo define application endpoints
13.How can you create a custom auto-configuration in Spring Boot?
- ABy disabling all existing configurations
- BBy using a different framework
- CBy creating a class annotated with @Configuration and listing it in spring.factories
- DBy modifying the Spring Boot source code
14.What is the effect of setting the property spring.main.allow-bean-definition-overriding to true?
- AIt disables all beans
- BIt prevents bean definitions from being overridden
- CIt allows bean definitions to be overridden
- DIt enables all beans
15.Which annotation can be used to conditionally enable a configuration based on a property value?
- A@ConditionalOnResource
- B@ConditionalOnExpression
- C@ConditionalOnMissingBean
- D@ConditionalOnProperty