SpringBoot 整合 Mybatis 出现 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
错误描述
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):com.moonce.xxxMapper:findList
原因
1.命名错误
首先检查 Mapper 接口和 XML 文件中是否有格式错误
2.没有指定 mybatis 中得 xml 文件路径
3.Mapper 文件未加载,所以在程序启动时,就找不到对应的映射文件,导致的这个错误。
<build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> </build>
4.mybatis 配置在 yml 写法不对,mybatis 配置不属于 spring 下,应顶格写
错误写法
spring: profiles: active: dev mybatis: type-aliases-package: com.moonce.user.entity mapper-locations: classpath*:mapping/*.xml
正确写法
spring: profiles: active: dev mybatis: type-aliases-package: com.moonce.user.entity mapper-locations: classpath*:mapping/*.xml
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于