mybatis报错nested exception is org.apache.ibatis.builder.IncompleteElementException:Could not find par

一.问题描述

2021-06-11 09:12:29.869 [http-nio-8080-exec-3] INFO  com.course.controller.UserManger - request url is:http://localhost:8080/v1/login
2021-06-11 09:12:29.869 [http-nio-8080-exec-3] INFO  com.course.controller.UserManger - tt
2021-06-11 09:12:29.869 [http-nio-8080-exec-3] INFO  com.course.controller.UserManger - 123
2021-06-11 09:12:29.869 [http-nio-8080-exec-3] ERROR o.a.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.IncompleteElementException: Could not find parameter map com.course.model.UserMap] with root cause
java.lang.IllegalArgumentException: Parameter Maps collection does not contain value for com.course.model.UserMap
	at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:875)
	at org.apache.ibatis.session.Configuration.getParameterMap(Configuration.java:647)
	at org.apache.ibatis.builder.MapperBuilderAssistant.getStatementParameterMap(MapperBuilderAssistant.java:318)
	at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:296)
	at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:109)
	at org.apache.ibatis.session.Configuration.buildAllStatements(Configuration.java:775)
	at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:706)
	at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:701)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
	at com.sun.proxy.$Proxy69.selectOne(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166)
	at com.course.controller.UserManger.login(UserManger.java:40)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:870)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:776)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

二.问题解决

1.发现问题出在了第40行
mybatis报错nested exception is org.apache.ibatis.builder.IncompleteElementException:Could not find par
检查mapper.xml对应的SQL语句

 <select id="selectByUserName" parameterType="java.lang.String" resultMap="UserMap">
        select * from user where username=#{userName}
    </select>

这个SQL语句本身是没有错误的;

检查mapper.xml其他语句是否错误

 <!--    2.添加用户接口所调用SQL-->
    <insert id="addUser" parameterMap="UserMap">
        insert into user(username,password,age,sex,permission,is_delete)
        values(#{userName},#{password},#{age},#{sex},#{permission},#{isDelete})
    </insert>

这里有一个地方我用的parameterMap传参,意思是parametermap 就是以map的方式传参数进来;
我传的参数是一个user对象,
mybatis报错nested exception is org.apache.ibatis.builder.IncompleteElementException:Could not find par

2.修改如下:
mybatis报错nested exception is org.apache.ibatis.builder.IncompleteElementException:Could not find par

3.再次运行
报错消失

2021-06-11 09:31:30.595 [http-nio-8080-exec-2] INFO  com.course.controller.UserManger - tt
2021-06-11 09:31:30.595 [http-nio-8080-exec-2] INFO  com.course.controller.UserManger - 123
2021-06-11 09:31:30.599 [http-nio-8080-exec-2] INFO  com.course.controller.UserManger - userOld is :User(id=1, us
erName=tt, password=123, age=26, sex=0, permission=0, isDelete=0)
2021-06-11 09:31:30.599 [http-nio-8080-exec-2] INFO  com.course.controller.UserManger - 登录成功------>用户是tt
2021-06-11 09:31:30.714 [http-nio-8080-exec-5] INFO  com.course.controller.UserManger - verifyCookie方法获取到的c
ookie是[Ljavax.servlet.http.Cookie;@2b24951e
2021-06-11 09:31:30.733 [http-nio-8080-exec-5] INFO  com.course.controller.UserManger - getUserInfo查询到的用户数
量是1
2021-06-11 09:31:30.810 [http-nio-8080-exec-7] INFO  com.course.controller.UserManger - verifyCookie方法获取到的c
ookie是[Ljavax.servlet.http.Cookie;@5ef8bd65
2021-06-11 09:31:30.812 [http-nio-8080-exec-7] INFO  com.course.controller.UserManger - getUserInfo查询到的用户数
量是2
2021-06-11 09:31:30.861 [http-nio-8080-exec-9] INFO  com.course.controller.UserManger - verifyCookie方法获取到的c
ookie是[Ljavax.servlet.http.Cookie;@79b2e2a8
2021-06-11 09:31:30.867 [http-nio-8080-exec-9] INFO  com.course.controller.UserManger - 调用SQL更新用户信息成功

mybatis报错nested exception is org.apache.ibatis.builder.IncompleteElementException:Could not find par

上一篇:Tomcat安全基线


下一篇:tomcat统一管理环境变量setenv.sh