Mybatis MapperScan basePackages

 项目中,两个模块中都放了 Mapper,如下所示

@MapperScan(basePackages ={"com.vipsoft.his.mapper","com.vipsoft.his.sdfyy.mapper"} )

为了方便,两个合成了一个,

@MapperScan(basePackages ={"com.vipsoft.his"} )

问题来了

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

Description:

Field fromHisApi in com.vipsoft.his.web.controller.CustodyController required a single bean, but 2 were found:
  - fromHisApiImpl: defined in file [D:\Projects\80.HIS\Test\Master\vipsoft-his-sdfyy\target\classes\com\vipsoft\his\sdfyy\service\impl\FromHisApiImpl.class]
  - IFromHisApi: defined in file [D:\Projects\80.HIS\Test\Master\vipsoft-his-api\target\classes\com\vipsoft\his\api\IFromHisApi.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

解决办法【不好】:在实现类上增加 @Primary,或者在调用的地方加上 @Qualifier("fromHisApiImpl") 

 

Mybatis MapperScan basePackages

上一篇:SpringBoot获取启动类Application所在包路径


下一篇:IOS错误Could not produce class with ID