The _____ annotation in Spring is used to give a preference to a bean when multiple beans of the same type exist.
- @Primary
- @Qualifier
- @PreferencedBean
- @Priority
The @Primary annotation in Spring is used to give a preference to a bean when multiple beans of the same type exist. It tells Spring which bean should be considered as the primary candidate for autowiring when there are multiple candidates of the same type. The other options, such as @Qualifier, @PreferencedBean, and @Priority, do not serve the same purpose as @Primary.
Loading...
Related Quiz
- In a microservices architecture using Spring Cloud, how is service registration managed?
- How can you perform Unit Testing in a Spring Boot application to ensure that the Security Configurations are working as expected?
- To externalize configuration properties in Spring Boot, the _____ annotation can be used on a configuration properties class.
- In Spring Boot, which annotation is used to conditionally enable caching only when a certain property is set?
- In Spring Boot, _____ allows developing reactive applications by providing an alternative to the traditional, servlet-based, blocking architecture.