Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to inject a specific bean using @Qualifier.
Spring Boot
@Autowired @Qualifier("paymentService") private Service [1];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the class name instead of the bean name.
Using a generic variable name that causes ambiguity.
✗ Incorrect
You need to specify the exact bean name to resolve ambiguity using @Qualifier or bean name injection.
2fill in blank
mediumComplete the annotation to specify which bean to inject.
Spring Boot
@Autowired @Qualifier("[1]") private Service service;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the quotes around the bean name.
Using the class name instead of the bean name.
✗ Incorrect
The @Qualifier annotation requires the exact bean name as a string to resolve ambiguity.
3fill in blank
hardFix the error in the injection by adding the correct annotation.
Spring Boot
@Autowired
[1]
private Service service; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Only renaming the variable without @Qualifier.
Using @Qualifier without specifying the bean name.
✗ Incorrect
To fix ambiguity, you must add @Qualifier with the bean name above the field or on the field declaration.
4fill in blank
hardFill both blanks to declare and inject the correct bean using @Qualifier.
Spring Boot
@Autowired @Qualifier("[1]") private [2] service;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing bean names and class types incorrectly.
Using a generic class type that does not match the bean.
✗ Incorrect
You specify the bean name in @Qualifier and the correct service class type for the variable.
5fill in blank
hardFill all three blanks to define two beans and inject one using @Qualifier.
Spring Boot
@Bean public [1] [2]() { return new [1](); } @Autowired @Qualifier("[2]") private [1] service;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for bean and qualifier.
Mismatching class type and bean name.
✗ Incorrect
Define a bean method with the class and bean name, then inject it using @Qualifier with the bean name.