数据库访问层,与baseservice 冲突

Blade 未结 1 630
Coral
Coral 剑童 2021-02-27 11:25

一、该问题的重现步骤是什么?

  1. 业务结构如下

    ┃--comtroller

    ┃--service

    ┞ ----┕-----impl

    ┃--mapper



2.在impl 中 我方分别调用了 baseMapper 以及

手动注入了一个当前类的

    @Autowired
    private XxxxxMapper xxxxxMapper;

 


二、你期待的结果是什么?实际看到的又是什么?

是不是因为我们重复注入了所以导致了如下报错的问题



三、你正在使用的是什么产品,什么版本?在什么操作系统上?


四、请提供详细的错误堆栈信息,这很重要。

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-02-27 11:07:33.564 ERROR 1 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :

***************************
APPLICATION FAILED TO START
***************************

Description:

Field baseMapper in com.baomidou.mybatisplus.extension.service.impl.ServiceImpl required a single bean, but 2 were found:
        - org.springblade.modules.xxxx.mapper.xxxxMapper: defined in null
        - algorithmInfoMapper: defined in URL [jar:file:/home/jar/xxx.jar!
        /BOOT-INF/classes!/org/springblade/modules/xxx/mapper/xxxxMapper.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



五、若有更多详细信息,请在下面提供。

1条回答
  • 2021-02-27 12:42

    bean实例化了两次,导致不知道注入哪一个,所以报错了

    另外商业版答疑规则见:https://sns.bladex.cn/article-14990.html

    请将账号邮箱修改为下单购买授权的qq邮箱便可咨询商业版疑问



    0 讨论(0)
提交回复