Error creating bean with name 'com.southwind.mmall002.service.Impl.ProductCategoryServiceImplTest

created at 10-17-2021 views: 22


 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.southwind.mmall002.service.Impl.ProductCategoryServiceImplTest': Unsatisfied dependency expressed through field 'service'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.southwind.mmall002.service.ProductCategoryService' available: expected single matching bean but found 2: ProductCategoryService,productCategoryService

When using the test class to test, the above error occurred. The general meaning is that there is an interface and an implementation class in the service. The spring container does not know which one to use.


Here I add @Qualifier("ProductCategoryService") annotation to the injected class and add @Service("ProductCategoryService) to the ServiceImpl class. ") resolved the error. As shown below

ServiceImpl class


created at:10-17-2021
edited at: 10-17-2021: