Mapped Statements collection does not contain value for错误

今天用mybatis写简单的增删改查的时候遇到这个问题两次,第二次居然没有很快定位,所以把它写下来做个备份,其实这个问题网上答案很多,也写得很好,都是粗心出的错,比如文件名不对应之类的,可参考博客的说法,我的报错信息如下
Mapped Statements collection does not contain value for错误_第1张图片
具体信息贴一下:
Mapped Statements collection does not contain value for com.csair.test.user.dao.UserMapper.getAllUser
at org.apache.ibatis.session.Configuration StrictMap.get(Configuration.java:672)atorg.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:507)atorg.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:500)atorg.apache.ibatis.binding.MapperMethod.setupCommandType(MapperMethod.java:240)atorg.apache.ibatis.binding.MapperMethod.(MapperMethod.java:71)atorg.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:39)atcom.sun.proxy. Proxy14.getAllUser(Unknown Source)
at com.csair.test.user.service.impl.UserServiceImpl.getAllUserDto(UserServiceImpl.java:47)
at com.alibaba.dubbo.common.bytecode.Wrapper1.invokeMethod(Wrapper1.java)
at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory 1.doInvoke(JavassistProxyFactory.java:46)atcom.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72)atcom.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)atcom.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64)atcom.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper 1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper 1.invoke(ProtocolFilterWrapper.java:91)atcom.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)atcom.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper 1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper 1.invoke(ProtocolFilterWrapper.java:91)atcom.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60)atcom.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper 1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper 1.invoke(ProtocolFilterWrapper.java:91)atcom.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)atcom.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper 1.invoke(ProtocolFilterWrapper.java:91)
at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38)
at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper 1.invoke(ProtocolFilterWrapper.java:91)atcom.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol 1.reply(DubboProtocol.java:108)
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84)
at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170)
at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
at com.alibaba.dubbo.remoting.transport.dispather.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
可以看到报错第一行最后是mapper里调用的方法出错,后来才发现由于改了表结构,重新生成mpper.xml文件时自己写的方法没加进去,所以把id为getAllUser的sql加到mpper.xml即可

你可能感兴趣的:(Mapped Statements collection does not contain value for错误)