0
0
Spring Bootframework~10 mins

How auto-configuration works in Spring Boot - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable Spring Boot auto-configuration in the main application class.

Spring Boot
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.[1](Application.class, args);
    }
}
Drag options to blanks, or click blank then click option'
Alaunch
Bstart
Cexecute
Drun
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method name other than 'run' causes the app not to start.
Forgetting to call any method to launch the app.
2fill in blank
medium

Complete the annotation to enable Spring Boot's auto-configuration feature.

Spring Boot
@[1]
public class Application {}
Drag options to blanks, or click blank then click option'
AEnableAutoConfiguration
BSpringBootApplication
CAutoConfigure
DConfiguration
Attempts:
3 left
💡 Hint
Common Mistakes
Using only @EnableAutoConfiguration misses component scanning.
Using @Configuration alone does not enable auto-configuration.
3fill in blank
hard

Fix the error in the code to correctly exclude a specific auto-configuration class.

Spring Boot
@SpringBootApplication(exclude = [1].class)
public class Application {}
Drag options to blanks, or click blank then click option'
ADataSourceAutoConfiguration
BEnableAutoConfiguration
CSpringBootApplication
DAutoConfigure
Attempts:
3 left
💡 Hint
Common Mistakes
Using annotation names instead of class names causes errors.
Misspelling the class name.
4fill in blank
hard

Fill both blanks to create a conditional auto-configuration class that activates only if a bean is missing.

Spring Boot
@Configuration
@ConditionalOnMissingBean([1].class)
public class [2]AutoConfiguration {}
Drag options to blanks, or click blank then click option'
ADataSource
BJdbcTemplate
CCache
DSecurity
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated bean types causes the condition to fail.
Mismatching class names and bean types.
5fill in blank
hard

Fill all three blanks to define a custom auto-configuration class with proper annotations and bean method.

Spring Boot
@Configuration
@ConditionalOnClass([1].class)
public class [2]AutoConfiguration {
    @Bean
    public [1] [3]() {
        return new [1]();
    }
}
Drag options to blanks, or click blank then click option'
ARestTemplate
BMyService
CrestTemplate
DmyService
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for class and bean method.
Missing @Bean annotation.