且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

springboot 集成mybatis Invalid bound statement (not found)异常

更新时间:2022-03-05 13:21:13

场景

在使用springboot集成mybatis的过程中出现一下异常。经过跟踪发现其实异常与springboot无关,主要是mybatis配置文件的原因。大家遇到类似问题,可直接进行定位。

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.antifraud.mapper.TestMapper.getTestList
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:214) ~[mybatis-3.4.0.jar:3.4.0]
    at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48) ~[mybatis-3.4.0.jar:3.4.0]
    at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59) ~[mybatis-3.4.0.jar:3.4.0]
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) ~[mybatis-3.4.0.jar:3.4.0]
    at com.sun.proxy.$Proxy68.getTestList(Unknown Source) ~[na:na]

问题定位及解决

首先定位问题在Mapper配置文件。

主要检查配置文件中此段代码:


<mapper namespace="com.antifraud.domain.Test" >

1

以上代码是我错误的示范。正式因为本应该配置为对应mapper类的namespace配置成domain类了。

因此,将上面的类指定为对应的mapper类即可。