Creating and Configuring Custom @Qualifier Annotation

You may also like...

Leave a Reply

1 Comment on "Creating and Configuring Custom @Qualifier Annotation"

avatar
  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 »