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
在使用測試類測試的時候,出現了以上報錯。大致意思就是service里面有一個接口,一個實現類,spring容器不知道該用哪一個,在這里我通過在注入類中添加@Qualifier("ProductCategoryService")注解,在ServiceImpl類中增加@Service("ProductCategoryService")解決了錯誤。如下圖