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

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

绿林寻猫
2021-12-08 / 0 评论 / 200 阅读 / 正在检测是否收录...

 

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

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

Description:

Field sysJobService in com.comet.controller.SysJobController required a single bean, but 2 were found:
	- sysJobServiceImpl: defined in file [G:\IdeaProject\comet\comet-quartz\target\classes\com\comet\service\impl\SysJobServiceImpl.class]
	- ISysJobService: defined in file [G:\IdeaProject\comet\comet-quartz\target\classes\com\comet\service\ISysJobService.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

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

 

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

0

评论 (0)

取消