Spring Boot MyBatis BindingException: Invalid bound statement (not found)
MyBatis Spring Boot About 1,195 words错误信息
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.mapper.TestMapper.insert
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:229)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:53)
at org.apache.ibatis.binding.MapperProxy.lambda$cachedInvoker$0(MapperProxy.java:96)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at org.apache.ibatis.util.MapUtil.computeIfAbsent(MapUtil.java:36)
at org.apache.ibatis.binding.MapperProxy.cachedInvoker(MapperProxy.java:94)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
at jdk.proxy2/jdk.proxy2.$Proxy89.insert(Unknown Source)
错误原因
没有配置mapper
位置。
解决方法
方法一
启动类中指定要扫描的Mapper
接口的包路径。
import org.mybatis.spring.annotation.MapperScan;
@SpringBootApplication
@MapperScan({"com.example.mapper1", "com.example.mapper2"})
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
}
方法二
配置文件中指定xml
的位置。
mybatis:
mapper-locations: classpath:mapper/*.xml
Views: 1,150 · Posted: 2024-05-19
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...