学习仿牛客网社区开发项目
报错
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.muller.community.CommunityApplicationTests': Unsatisfied dependency expressed through field 'alphaDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.muller.community.dao.AlphaDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=alphaDaoHibernateImpl)}
分析
它说创建Bean失败,“alphaDao”表示的依赖项不满足。去测试文件中看创建alphaDao属性的命令
@Qualifier 注释的内容是我们需要的实现类,去实现类发现我已经给这个Bean起了新名字AlphaDaoHibernate
解决方法
改为@Qualifier(“AlphaDaoHibernate”)