Advanced Customization of Spring Boot Auto-Configuration
An advanced quiz on customizing auto-configuration in Spring Boot applications.
Questions in this quiz
10 questions on Advanced Customization of Spring Boot Auto-Configuration. Work through them here, then start the quiz to answer them and see your score.
1.What is the primary purpose of the @ConditionalOnMissingBean annotation in Spring Boot?
- ATo exclude a bean from auto-configuration
- BTo load a bean only if another bean is missing
- CTo define a bean only if a specific property is set
- DTo ensure a bean is always loaded
2.Which class should you extend to create a custom auto-configuration in Spring Boot?
- AAbstractAutoConfiguration
- BAutoConfiguration
- CAutoConfigurationImportSelector
- DNone of the above
3.How can you exclude a specific auto-configuration class from being applied?
- AUsing @EnableAutoConfiguration(exclude = {ClassName.class})
- BUsing @ConditionalOnMissingAutoConfiguration(ClassName.class)
- CUsing @AutoConfigurationExclude(ClassName.class)
- DUsing @ExcludeAutoConfiguration(ClassName.class)
4.What is the role of META-INF/spring.factories in Spring Boot auto-configuration?
- AIt configures the application’s properties
- BIt specifies which auto-configuration classes to load
- CIt lists all beans to be auto-configured
- DIt defines the order of auto-configuration
5.In which scenario would you use @ConditionalOnProperty?
- ATo load a bean based on the presence of a specific property
- BTo load a bean only if another bean is present
- CTo exclude a bean if a property is set
- DTo define a bean conditionally based on the environment
6.Which annotation is used to conditionally load a bean based on the presence of a class in the classpath?
- A@ConditionalOnBean
- B@ConditionalOnResource
- C@ConditionalOnMissingClass
- D@ConditionalOnClass
7.What is the effect of setting spring.autoconfigure.exclude in application.properties?
- AIt includes additional auto-configuration classes
- BIt sets the priority of auto-configurations
- CIt disables all auto-configurations
- DIt excludes specific auto-configuration classes
8.How can you ensure a custom auto-configuration is applied after a specific existing configuration?
- AUsing @AutoConfigureOrder
- BUsing @AutoConfigureAfter
- CUsing @ConditionalOnAfter
- DUsing @AutoConfigureBefore
9.Which of the following is NOT a valid condition for conditional auto-configuration?
- A@ConditionalOnExpression
- B@ConditionalOnResource
- C@ConditionalOnMissingProperty
- D@ConditionalOnWebApplication
10.What is the purpose of @EnableAutoConfiguration in a Spring Boot application?
- ATo manually configure all beans
- BTo configure application security
- CTo disable all auto-configurations
- DTo enable automatic configuration of beans based on classpath settings