Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans

编程知识 更新时间:2023-05-02 05:23:17

mybatis-plus报错,之前使用mybatis-plus却没有遇到过的问题

Description:

Field baseMapper in com.baomidou.mybatisplus.extension.service.impl.ServiceImpl required a single bean, but 3 were found:
	- permissionMapper: defined in file [D:XXX\mapper\PermissionMapper.class]
	- userMapper: defined in file [D:XXX\mapper\UserMapper.class]
	- userRoleMapper: defined in file [D:XXX\mapper\UserRoleMapper.class]


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

Disconnected from the target VM, address: '127.0.0.1:58072', transport: 'socket'

Process finished with exit code 1

它也给了两个解决办法
1.把其中一个bean加上@Primary注解,就可以作为默认使用,
2.在注入的属性添加@Qualifier指定beanName,以明确使用哪一个bean
但是经过测试我把其他bean都删掉只剩一个也是报错,所以这两个办法并不能帮助我解决问题。
最后查资料发现可以去扫描一下mp的mapper的路径就没问题了
“com.baomidou.mybatisplus.core.mapper”

如果泛型没有写上可能也会出现这个问题,注意避坑

更多推荐

Consider marking one of the beans as @Primary, updating the consumer to accept m

本文发布于:2023-04-26 05:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/189cf178026dddd9491e9354bafa242d.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Primary   beans   marking   updating   multiple

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 104347文章数
  • 26211阅读数
  • 0评论数