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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *