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

 

异常问题为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包中才出现上述问题

SpringBoot+Mybatis启动项目*required a single bean, but 2 were found*_第1张图片

 

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

SpringBoot+Mybatis启动项目*required a single bean, but 2 were found*_第2张图片

你可能感兴趣的:(异常问题)