Invalid bound statement (not found): com.example.demo.dao.mapper.clDao.queryAll

spring-boot配置Mybatis的时候总是出现这样的情况。
Whitelabel Error Page
控制台显示错误:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.demo.dao.mapper.clDao.queryAll
at org.apache.ibatis.binding.MapperMethod S q l C o m m a n d . < i n i t > ( M a p p e r M e t h o d . j a v a : 235 )   [ m y b a t i s − 3.5.6. j a r : 3.5.6 ] a t o r g . a p a c h e . i b a t i s . b i n d i n g . M a p p e r M e t h o d . < i n i t > ( M a p p e r M e t h o d . j a v a : 53 )   [ m y b a t i s − 3.5.6. j a r : 3.5.6 ] a t o r g . a p a c h e . i b a t i s . b i n d i n g . M a p p e r P r o x y . l a m b d a SqlCommand.<init>(MapperMethod.java:235) ~[mybatis-3.5.6.jar:3.5.6] at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:53) ~[mybatis-3.5.6.jar:3.5.6] at org.apache.ibatis.binding.MapperProxy.lambda SqlCommand.<init>(MapperMethod.java:235) [mybatis3.5.6.jar:3.5.6]atorg.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:53) [mybatis3.5.6.jar:3.5.6]atorg.apache.ibatis.binding.MapperProxy.lambdacachedInvoker 0 ( M a p p e r P r o x y . j a v a : 115 )   [ m y b a t i s − 3.5.6. j a r : 3.5.6 ] a t j a v a . u t i l . c o n c u r r e n t . C o n c u r r e n t H a s h M a p . c o m p u t e I f A b s e n t ( C o n c u r r e n t H a s h M a p . j a v a : 1660 )   [ n a : 1.8. 0 1 71 ] a t o r g . a p a c h e . i b a t i s . b i n d i n g . M a p p e r P r o x y . c a c h e d I n v o k e r ( M a p p e r P r o x y . j a v a : 102 )   [ m y b a t i s − 3.5.6. j a r : 3.5.6 ] a t o r g . a p a c h e . i b a t i s . b i n d i n g . M a p p e r P r o x y . i n v o k e ( M a p p e r P r o x y . j a v a : 85 )   [ m y b a t i s − 3.5.6. j a r : 3.5.6 ] a t c o m . s u n . p r o x y . 0(MapperProxy.java:115) ~[mybatis-3.5.6.jar:3.5.6] at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) ~[na:1.8.0_171] at org.apache.ibatis.binding.MapperProxy.cachedInvoker(MapperProxy.java:102) ~[mybatis-3.5.6.jar:3.5.6] at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85) ~[mybatis-3.5.6.jar:3.5.6] at com.sun.proxy. 0(MapperProxy.java:115) [mybatis3.5.6.jar:3.5.6]atjava.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) [na:1.8.0171]atorg.apache.ibatis.binding.MapperProxy.cachedInvoker(MapperProxy.java:102) [mybatis3.5.6.jar:3.5.6]atorg.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85) [mybatis3.5.6.jar:3.5.6]atcom.sun.proxy.Proxy73.queryAll(Unknown Source) ~[na:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) ~[spring-aop-5.3.4.jar:5.3.4]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.3.4.jar:5.3.4]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.4.jar:5.3.4]

解决方法:

在application.properties里加上

mybatis.mapperLocations=classpath:com/example/demo/dao/sqlmap/*.xml

mapperLocations

或者是这一段路径写错了修改一下。之后便可以查询出来。

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用内容,"Invalid bound statement (not found): com.example.demo.mapper.UserMapper.getUserById" 是一个错误的绑定语句,表示找不到名为"com.example.demo.mapper.UserMapper.getUserById"的绑定语句。这通常是由于以下原因导致的: 1. SQL映射文件中没有定义名为"getUserById"的语句。 2. SQL映射文件中定义了"getUserById"语句,但是命名空间或语句的ID有误。 3. 未在启动类上添加正确的注解。 为了解决这个问题,你可以按照以下步骤进行操作: 1. 确保在SQL映射文件中定义了名为"getUserById"的语句,并且命名空间和语句的ID都是正确的。可以检查一下SQL映射文件中是否存在类似以下的代码: ```xml <select id="getUserById" parameterType="int" resultType="com.example.demo.model.User"> SELECT * FROM users WHERE id = #{id} </select> ``` 2. 确保在启动类上添加了正确的注解。根据提供的引用内容,你需要在启动类上添加`@MapperScan(value = "com.example.demo.mapper")`注解,以扫描并加载Mapper接口。 ```java @SpringBootApplication @MapperScan(value = "com.example.demo.mapper") public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } } ``` 请注意,上述代码中的"com.example.demo.mapper"应该是你实际的Mapper接口所在的包路径。 如果你已经按照上述步骤进行操作,但问题仍然存在,请检查一下你的代码和配置是否正确,并确保数据库连接等相关配置正确无误。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值