1.

What is @Qualifier and why it will be used?

Answer»

When we create more than one bean of the same type and we want to wire only one of them with a property, in that CASE, we can USE @QUALIFIER with @AUTOWIRED. Here is an example of the same.

public class UserProfile{   @Autowired   @Qualifier("firstUser")   PRIVATE User user;   public UserProfile(){     System.out.println("Hi" );   }   public void printAge() {     System.out.println("Age of the user: " + user.getAge() );   }   public void printName() {     System.out.println("Name of the user: " + user.getName() );   } }


Discussion

No Comment Found