admin管理员组

文章数量:1794759

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

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

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”

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

本文标签: PRIMARYbeansmarkingupdatingmultiple