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)}
- 原因:注入了一个重复的bkdnaf
我在接口中写了@Mapper注解,又在主类中使用了@MapeprScan注解,重复注入了bean
接口类
主类 - 解决办法
- 解决一:去掉MapperScan注解
- 解决二:去掉Mapper注解