事实上,一共有三种方式,我的程序里面并没有用@MapperScan(“com.xxx.dao”),而是采用@Mapper @Repository两个注解在mapper上,如下:
参考:https://blog.youkuaiyun.com/fengling_smile/article/details/129853866#:~:text=%40Repository%E6%B3%A8%E8%A7%A3%E6%98%AF%E7%94%A8%E4%BA%8E%E6%A0%87%E8%AE%B0%E6%95%B0%E6%8D%AE%E8%AE%BF%E9%97%AE%E5%B1%82%E7%9A%84%E7%BB%84%E4%BB%B6%E7%9A%84%E6%B3%A8%E8%A7%A3%EF%BC%8C%E5%AE%83%E4%BC%9A%E8%A2%ABspring%E6%89%AB%E6%8F%8F%E5%B9%B6%E6%B3%A8%E5%85%A5%E5%88%B0ioc%E5%AE%B9%E5%99%A8%E4%B8%AD%E3%80%82,%E5%8D%B3%E4%BD%BF%E6%B2%A1%E6%9C%89%E4%BD%BF%E7%94%A8%40MapperScan%E6%B3%A8%E8%A7%A3%E6%88%96MapperScannerConfigurer%EF%BC%8C%E5%8F%AA%E8%A6%81%40Repository%E6%B3%A8%E8%A7%A3%E6%A0%87%E8%AE%B0%E7%9A%84%E7%BB%84%E4%BB%B6%E4%B8%8EMybatis%E7%9A%84mapper%E6%8E%A5%E5%8F%A3%E5%AE%9E%E7%8E%B0%E7%9B%B8%E5%90%8C%EF%BC%8C%E5%AE%83%E4%B9%9F%E5%8F%AF%E4%BB%A5%E7%94%9F%E6%95%88%E3%80%82
https://blog.youkuaiyun.com/u012060033/article/details/108453298
同理 ,数据源的配置 springboot也提供多种方式把datasource加入到容器:
Spring Boot的数据源配置 https://cloud.tencent.com/developer/article/2258704