好文一篇,验证过了,没有问题的:
https://www.jianshu.com/p/ff5af6c59365?utm_source=oschina-app
踩坑分享:
我是改造以前的单数据源项目。本不想动原来的mapper类文件目录路径的,后来发现不行。就给原来的mapper类单独建立了包用来存放,和新数据源mapper的包路径平行,这样问题就解决了。
踩坑分享:
问题:Invalid bound statement (not found)
原因是mapper.xml文件没有加载到导致的
缺少红框的配置
添加 sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:/mapper/*/*.xml")) 就可以解决问题了
另外下面这篇文章也瞟了下,可以顺便参考: