其他分享
首页 > 其他分享> > Mybatis MapperScan basePackages

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

 

标签:sdfyy,his,basePackages,vipsoft,MapperScan,Mybatis,com
来源: https://www.cnblogs.com/vipsoft/p/15035802.html