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"})


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM