阅读 218

springboot+mybatis,扫描不到mapper

springboot+mybatis,扫描不到mapper

  • 无法扫描到接口实现,'com.sclp.mapper.GenTableMapper' that could not be found.

Description:

Field genTableService in com.sclp.controller.GenController required a bean of type 'com.sclp.mapper.GenTableMapper' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)Action:

Consider defining a bean of type 'com.sclp.mapper.GenTableMapper' in your configuration.

需要在主启动类和mapper接口上分别使用@MapperScan@Mapper,将mapper注入spring容器;

  • @MapperScan注解将非mapper接口扫描到容器,Field genTableService in com.sclp.controller.GenController required a single bean, but 2 were found

Description:

Field genTableService in com.sclp.controller.GenController required a single bean, but 2 were found:
	- genTableServiceImpl: defined in file [D:\Work_soft\Workplace\sclp\sclp-gen\target\classes\com\sclp\service\impl\GenTableServiceImpl.class]
	- IGenTableService: defined in file [D:\Work_soft\Workplace\sclp\sclp-gen\target\classes\com\sclp\service\IGenTableService.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

在使用@MapperScan注解时指定扫描范围@MapperScan(basePackages={"com.sclp.mapper"})

来源:https://www.cnblogs.com/jinit/p/14794150.html


服务器评测 http://www.cncsto.com/ 

服务器测评 http://www.cncsto.com/ 


文章分类
后端
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐