mybatis-plus自定义mapper报org.apache.ibatis.binding.BindingException: Invalid bound statement(not found)

it2023-11-03  99

今天在springboot的项目中,需要用到自定义的mapper,之前一直使用mybatis-plus自动生成的mapper,一直可以正常使用,今天因为需求需要,自定义了mapper,但是一直报这个错: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

似乎找了全网,试了各种办法,都没有解决,花了大半天,依然无果,只好乖乖debug进去mybatis-plus的orm的逻辑中,忽然发现是可以正确拿到dao上面定义的接口和方法,但是就是拿不到xml的配置数据

直觉告诉自己,应该是这里的问题。

在springboot 的入口里面只是使用注解:

@MapperScan(basePackages = {"xxx.xxx.**.dao"})

只是扫描了dao但是没有扫描和加载xml资源 因此在property文件中,配置mybatis-plus的mapper.xml文件的目录:

mybatis-plus.mapper-locations=classpath*:/mybatis/mappers/**.xml

就这样,重启了之后,竟然解决问题了,看来,有时间还是要好好研究下mybatis-plus里面的原理。

最新回复(0)