SpringBoot+Mybatis启动项目*required a single bean, but 2 were found*

柔光的暖阳◎ 2023-06-08 10:55 206阅读 0赞

异常问题为controller中存在多个相同的实例

  1. ***************************
  2. APPLICATION FAILED TO START
  3. ***************************
  4. Description:
  5. Field sysJobService in com.comet.controller.SysJobController required a single bean, but 2 were found:
  6. - sysJobServiceImpl: defined in file [G:\IdeaProject\comet\comet-quartz\target\classes\com\comet\service\impl\SysJobServiceImpl.class]
  7. - ISysJobService: defined in file [G:\IdeaProject\comet\comet-quartz\target\classes\com\comet\service\ISysJobService.class]
  8. Action:
  9. 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

我个人在配置映射时没有制定到mapper包中才出现上述问题

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMzY5OTQ0_size_16_color_FFFFFF_t_70

改成这样就能成功启动并访问数据库

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwMzY5OTQ0_size_16_color_FFFFFF_t_70 1

发表评论

表情:
评论列表 (有 0 条评论,206人围观)

还没有评论,来说两句吧...

相关阅读