目录
1 问题描述
SpringBoot+Mybatis多个模块项目,扫描不到*Mapper.xml文件
2 异常信息
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.wen.system.mapper.AppTestMapper.selectByPage
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:53)
at org.apache.ibatis.binding.MapperProxy.lambda$cachedInvoker$0(MapperProxy.java:108)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
at org.apache.ibatis.util.MapUtil.computeIfAbsent(MapUtil.java:35)
at org.apache.ibatis.binding.MapperProxy.cachedInvoker(MapperProxy.java:95)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
at com.sun.proxy.$Proxy159.selectByPageMysql(Unknown Source)
at com.wen.system.AppTestMapperTest.selectByPage(AppTestMapperTest.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
...
3 yml配置
3.1 修改前
mybatis:
# type-aliases-package: com.wen.system
mapper-locations: classpath:mapper/**/*.xml
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
3.2 修改后
mybatis:
# type-aliases-package: com.wen.system
mapper-locations: classpath*:mapper/**/*.xml
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
3.3 总结
对于多模块项目应该在classpath后面加*