yanakai
yanakai
2019-08-02 17:48
采纳率: 50%
浏览 1.1k
已采纳

springboot项目集成通用Mapper接口报错

springboot项目创建了BaseMapper继承通用mapper接口,单个业务的mapper继承BaseMapper接口没有问题但是再有一个业务mapper继承baseMapper程序启动就会报错 如下

Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.dudu.common.mybatis.MyBaseMapper<?>' available: expected single matching bean but found 2: sysRoleInfoMapper,sysUserInfoMapper
at org.springframework.beans.factory.config.DependencyDescriptor.resolveNotUnique(DependencyDescriptor.java:221) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1229) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:520) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:636) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:180) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:321) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
... 38 common frames omitted

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

5条回答 默认 最新

  • cccfire
    杨园亮 2019-08-02 17:52
    已采纳

    你是不是复制粘贴的sysUserInfoMapper这个mapper有两个全局搜下

    点赞 评论
  • lucklilili
    YaPengLi. 2019-08-02 17:56

    你的mapper重复了小伙

    点赞 评论
  • d592571519
    C君. 2019-08-02 18:10

    expected single matching bean but found 2: sysRoleInfoMapper,sysUserInfoMapper

    点赞 评论
  • doncha
    doncha 2019-08-02 18:16

    我之前也遇到过,不过我错误的地方是在继承通用控制器BaseController的时候,原因是因为我在BaseController上面添加了注解@Controller,导致其他控制器在引用它的时候,创建了两个相同的BaseController bean,你的情况应该也跟我类似吧,去通用接口BaseMapper上面看看有没有添加什么注解,导致其他接口在引用它的时候创建了两个相同的bean

    点赞 评论
  • lisu061714112
    苏三说技术 2019-08-04 16:34

    mapper中没有设置id吧?

    点赞 评论

相关推荐