Springboot整合mybati的时候出现的错误
 Error creating bean with name 'com.example.mybati.BankTest': Unsatisfied dependency expressed through field 'bankMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.mybati.mapper.BankMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

  1. 原因:注入了一个重复的bkdnaf
    我在接口中写了@Mapper注解,又在主类中使用了@MapeprScan注解,重复注入了bean
    接口类

    主类
  2.  解决办法
    1. 解决一:去掉MapperScan注解
    2. 解决二:去掉Mapper注解
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐