天天看点

java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for

java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for edu.hpu.mapper.ExamsMapper.addExam

使用IJ ssm整合的项目报了这么一个错误,更详细错误信息:

java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for edu.hpu.mapper.ExamsMapper.addExam org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:672) org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:507) org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:500) org.apache.ibatis.binding.MapperMethod.setupCommandType(MapperMethod.java:240) org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:71) org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:39) com.sun.proxy.$Proxy17.addExam(Unknown Source) edu.hpu.service.impl.FacultyServiceImpl.addExamsAndDetail(FacultyServiceImpl.java:62) edu.hpu.controller.FacultyController.addExams(FacultyController.java:197) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498) org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) javax.servlet.http.HttpServlet.service(HttpServlet.java:650) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

经过了查询,发现我的错误是Exams.xml中的方法和接口中的方法名不一致,修改一下就成功解决了。

发生这个异常的解决方式:

1、检查查interface中定义的方法和mapper映射的xml文件中定义的方法名、参数等是否一致。

2、检查mapper映射文件中< namespace="">映射到相应的接口的路径、名称是否正确。

3、检查.target中有没有对应的mapper文件夹,如不存在删除target下的文件,下次加载时会自动生成。