admin管理员组文章数量:1320918
服务层继承ISevice引发的Consider marking one of the beans as @Primary错误解释
- 简介
- 错误信息
- 错误原因
- 解决办法
简介
今天写项目时想用lambdaQueryWrapper 时,想用链式操作,之后我的service服务层继承于IService,我的ServiceImpl同样继承于ServiceImpl,最后启动项目后发现出现了这样的报错
错误信息
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
错误原因
根据发生这个错误后,经过我的筛查,发现MyBatis-plus 的IService.的ServiceImpl实现类中有一个 M baseMapper字段。
public class ServiceImpl<M extends BaseMapper<T>, T> implements IService<T> {
protected Log log = LogFactory.getLog(this.getClass());
@Autowired
protected M baseMapper;
报错的错误无非就是有两个Mapper存在,一个存在于ServiceImpl的baseMapper,一个我自己继承于BaseMapper的mapper。bean找不到了。
解决办法
通过@Primary注解,给我们的实体Mapper加上该注解就能解决BUG。
本文标签: 错误MybatisServiceSpringBootamp
版权声明:本文标题:SpringBoot&Mybatis-Plus - 服务层Service继承ISevice引发的Consider marking one of the beans as @Primary错误解释 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/biancheng/1738335888a2076909.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论