Creating and Configuring Custom @Qualifier Annotation

You may also like...

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
1 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Manuel Jordan Recent comment authors
  Subscribe  
newest oldest
Notify of
Manuel Jordan
Guest
Manuel Jordan

Hello, your code is incorrect, really your custom qualifier never works. Just do the following: @Autowired private @DogType Animal dog; to @Autowired private @DogType Animal dog_; It appears: An exception occured while executing the Java class. Error creating bean with name 'shepperd': Unsatisfied dependency expressed through field 'dog_'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.memorynotfound.spring.core.autowired.Animal' available: expected single matching bean but found 2: cat,dog -> [Help 1] Your code only works because @Autowired has three resolutions: * By Type, in this case by Animal, Ok, here we have two candidates. * By @Qualifier, in this case you… Read more »