Which annotation is used to inject a bean dependency into a Spring component?
- @Autowired
- @Bean
- @Component
- @Inject
The @Autowired annotation is used to inject a bean dependency into a Spring component. It enables automatic injection of dependencies by type. When a bean of the required type is available in the Spring context, it will be injected into the annotated field or constructor parameter. This annotation simplifies the process of wiring components together in a Spring application.
Loading...
Related Quiz
- How would you implement a custom error response structure when an exception occurs in a Spring Boot application?
- To define a global default exception handler for unhandled exceptions in Spring Boot, you can use a _____ with the highest precedence.
- The _____ annotation in Spring Boot is used to test only the web layer by disabling full auto-configuration and applying only relevant web configurations.
- How can you handle exceptions at the @RestController level, and how is it different from using @ControllerAdvice?
- What considerations should be taken into account when designing API endpoints using Request Mapping annotations in Spring Boot?