Posts

Showing posts with the label Resolve org.springframework.beans.factory.NoUniqueBeanDefinitionException

How To Resolve 'org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean ....' Using @Qualifier Annotation?

Image
Hello everyone, in this article we will learn how to resolve org.springframework.beans.factory. NoUniqueBeanDefinitionException : No qualifying bean of type 'com.example.demo.components.Human' available: expected single matching bean but found 2: employee,employer using @Qualifier Annotation or using @Primary Annotation. Before going to the example just a quick overview of NoUniqueBeanDefinitionException and @Qualifier Annotation. NoUniqueBeanDefinitionException: The ' org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type available: expected single matching bean but found ' will be thrown when the bean is auto-wired that matches two or more loaded beans in the spring boot application context. As a result, the bean could not be auto-wired.  The ApplicationContext represents the Spring IoC container and is responsible for instantiating, configuring, and assembling the aforementioned beans. @Qualifier  Annotation: The @Qualifier a