Creating and Configuring Custom @Qualifier Annotation

You may also like...

Subscribe
Notify of
guest
1 Comment
Oldest
Newest
Inline Feedbacks
View all comments
Manuel Jordan
Manuel Jordan
March 20, 2018 19:10

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 »

1
0
Would love your thoughts, please comment.x
()
x