org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.southwind.mmall002.service.Impl.ProductCategoryServiceImplTest':


 

 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")解決了錯誤。如下圖

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 【實戰問題】【14】org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'xxMapper' Springboot異常:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController' org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'statisticalMapper' defined in file Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'advertiseRestControll mybatis Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'homeControll Redis——解決“org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisReferenceResolver': Unsatisfied dependency expressed through constructor parameter 0” 報錯Error creating bean with name 'orderController': Unsatisfied dependency expressed through field 'orderService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'indexServiceImpl': Unsatisfied dependency expressed through field 'indexDao'; nested exception is org.s 【spring boot】使用注解@ConfigurationProperties讀取配置文件時候 報錯 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rocketmqAutoConfiguration': Unsatisfied dependenc org.springframework.beans.factory.UnsatisfiedDependencyException
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM