多模块项目,mybatis报错Invalid bound statement (not found)
2022-01-07 14:43:03.030 ERROR 18120 --- [schedule-pool-1] com.inkyi.system.service.SysLogService : Invalid bound statement (not found): com.inkyi.system.mapper.SysOperLogMapper.insertSelective
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.inkyi.system.mapper.SysOperLogMapper.insertSelective
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:235) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:53) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.binding.MapperProxy.lambda$cachedInvoker$0(MapperProxy.java:108) ~[mybatis-3.5.9.jar:3.5.9]
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705) ~[na:na]
at org.apache.ibatis.util.MapUtil.computeIfAbsent(MapUtil.java:35) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.binding.MapperProxy.cachedInvoker(MapperProxy.java:95) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86) ~[mybatis-3.5.9.jar:3.5.9]
at com.sun.proxy.$Proxy81.insertSelective(Unknown Source) ~[na:na]
at com.inkyi.system.service.SysLogService.insertOperlog(SysLogService.java:21) ~[main/:na]
at com.inkyi.framework.manager.AsyncFactory$1.run(AsyncFactory.java:88) ~[main/:na]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java) ~[na:na]
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
项目模块如下:
Mapper.xml和Mapper 类之间是100%确定没问题的。
那就是配置问题,检查置文件中扫描Mapper.xml的配置
#mybatis
mybatis.type-aliases-package=com.inkyi.*.entity
mybatis.mapper-locations=classpath:mapper/*/*.xml
将
mybatis.mapper-locations=classpath:mapper/*/*.xml
改为
mybatis.mapper-locations=classpath*:mapper/*/*.xml
classpath:只会扫描本项目下的class目录
classpath*: 会扫描Jar包中的class目录