mybatis-plus invalid bound statement (not found)
时间: 2023-05-03 19:07:48 浏览: 122
mybatis-plus invalid bound statement (not found) 出现的原因一般是因为未能正确绑定 SQL 语句和 Mapper 方法,可能是 Mapper 文件中定义的语句 ID 和实际运行时调用的语句 ID 不一致,或者是 XML 中定义的 namespace 与 Mapper 类中的 @Mapper 注解值不一致。解决方法一般有以下几种:
1. 检查 Mapper 文件中定义的语句 ID 是否正确,特别是在使用 @SelectProvider 注解时,要确保 SQL 语句 ID 的命名规则与实际调用的方法名称一致。
2. 检查 Mapper 类上的 @Mapper 注解值是否正确,要保证 namespace 与 Mapper 类的全限定名一致。
3. 检查 Mapper 文件是否被正确加载,可以通过在 Mybatis 配置文件中增加 <mapper resource="" /> 或 <mapper class="" /> 来加载 Mapper 文件。
4. 可以使用 @MapperScan 注解扫描 Mapper 接口所在的包,以确保 Mapper 文件被正确加载。
5. 如果使用的是 Spring Boot,可以尝试将 mybatis-plus.mapper-locations 属性设置为 Mapper 文件的路径,以确保 Mapper 文件被正确加载。
以上是 mybatis-plus invalid bound statement (not found) 的解决方法,一般能够解决这种问题。