Mybatis MapperScan basePackages
阿新 • • 發佈:2021-07-20
專案中,兩個模組中都放了 Mapper,如下所示
@MapperScan(basePackages ={"com.vipsoft.his.mapper","com.vipsoft.his.sdfyy.mapper"} )
為了方便,兩個合成了一個,
@MapperScan(basePackages ={"com.vipsoft.his"} )
問題來了
*************************** APPLICATION FAILED TO START *************************** Description: Field fromHisApi incom.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")