错误提示:
Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:178)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:38)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:49)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:42)
at com.sun.proxy.$Proxy125.selectItemPayRate(Unknown Source)
at com.fisher.wms.job.WarehouseDayFeeJob.doExecute(WarehouseDayFeeJob.java:65)
… 10 more
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:768)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:603)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:596)
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:176)
… 15 more
Mabatis提示mapper方法找不到,首先排查了命名问题:
1.检查xml文件的namespace和package名称一致。
2.检查了函数名称,标签里面的属性parameterType、 resultType等无误。
3.在pom.xml中加了配置:
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
还是没能解决此问题,最后发现这个类加了@Qualifier注解:
@Qualifier注解用于当存在多个相同类型的bean时指定装配的bean,使用使用@Qualifier配合@Autowired,避免BeanCreationException异常。
仔细检查发现@Qualifier指定的名字与该类定义的名字不同:
修改@Qualifier指定的名字后,问题解决。