>"/>
首页

解决mybatis的org.apache.ibatis.builder.IncompleteElementException: Could not find result map com..UserDTO异常问题

标签:mybatis,IncompleteElementException,异常,ibatis     发布时间:2018-07-04   

一、前言

关于mybatis使用映射XML配置时报"org.apache.ibatis.builder.IncompleteElementException: Could not find result map com..dto.UserDTO"异常,详细日志如下

 org.apache.ibatis.builder.IncompleteElementException: Could not find result map com.xwood.pms.dto.ldsp.dto.UserDTO@b@	at org.apache.ibatis.builder.MapperBuilderAssistant.setStatementResultMap(MapperBuilderAssistant.java:358) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:296) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:109) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	at org.apache.ibatis.session.Configuration.buildAllStatements(Configuration.java:718) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	at org.apache.ibatis.session.Configuration.hasStatement(Configuration.java:688) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	at org.apache.ibatis.session.Configuration.hasStatement(Configuration.java:683) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:183) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:44) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:59) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	at com.sun.proxy.$Proxy58.getPageList(Unknown Source) ~[?:?]@b@	at com.xwood.pms.dto.ldsp.service.impl.UserServiceImpl.getPageList(UserServiceImpl.java:22) ~[bin/:?]@b@	at com.xwood.pms.dto.ldsp.web.controller.UserController.getUserList(UserController.java:44) [bin/:?]@b@	at com.xwood.pms.dto.ldsp.web.controller.UserController$$FastClassBySpringCGLIB$$b30ce0e6.invoke(<generated>) [spring-core-3.2.13.RELEASE-3.2.13.RELEASE.jar:?]@b@	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) [spring-core-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:700) [spring-aop-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) [spring-aop-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:91) [spring-aop-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at com.xwood.pms.dto.ldsp.aop.LogAppendAdvice.logController(LogAppendAdvice.java:47) [bin/:?]@b@	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_11]@b@	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_11]@b@	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_11]@b@	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_11]@b@	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621) [spring-aop-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610) [spring-aop-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65) [spring-aop-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91) [spring-aop-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633) [spring-aop-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at com.xwood.pms.dto.ldsp.web.controller.UserController$$EnhancerBySpringCGLIB$$84433391.getUserList(<generated>) [spring-core-3.2.13.RELEASE-3.2.13.RELEASE.jar:?]@b@	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_11]@b@	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_11]@b@	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_11]@b@	at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_11]@b@	at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) [spring-web-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) [spring-web-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) [spring-webmvc-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:743) [spring-webmvc-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:672) [spring-webmvc-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:82) [spring-webmvc-3.2.13.RELEASE-3.2.13.RELEASE.jar:3.2.13.RELEASE]@b@	at com.xwood.basic.papp.web.DefWebRequestHandler.handleRequest(DefWebRequestHandler.java:61) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.web.filter.DefaultFilterChain.doFinal(DefaultFilterChain.java:64) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.web.filter.DefaultFilterChain.doFilter(DefaultFilterChain.java:57) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.pms.dto.ldsp.common.filter.XssSecurityFilter.doFilter(XssSecurityFilter.java:49) [bin/:?]@b@	at com.xwood.basic.papp.web.filter.DefaultFilterChain.doFilter(DefaultFilterChain.java:52) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.web.filter.impl.PostJsonToFormFilter.doFilter(PostJsonToFormFilter.java:38) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.web.filter.DefaultFilterChain.doFilter(DefaultFilterChain.java:52) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.web.DefWebDispatcher.handleRequest(DefWebDispatcher.java:134) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.sar.SARContextBean.handleWebRequest(SARContextBean.java:170) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.web.PAppWebRequestHandler.handleRequest(PAppWebRequestHandler.java:44) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.web.filter.DefaultFilterChain.doFinal(DefaultFilterChain.java:64) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.web.filter.DefaultFilterChain.doFilter(DefaultFilterChain.java:57) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.web.filter.impl.CommonWebFilter.doFilter(CommonWebFilter.java:46) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.web.filter.DefaultFilterChain.doFilter(DefaultFilterChain.java:52) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.web.DefPAppWebDispatcher.dispatch(DefPAppWebDispatcher.java:80) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.PAppContextBean.handleWebRequest(PAppContextBean.java:182) [papp-5.2.6.jar:5.2.6]@b@	at com.xwood.basic.papp.protocol.web.PappServlet.service(PappServlet.java:63) [papp-5.2.6.jar:5.2.6]@b@	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684) [jetty-servlet-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1496) [jetty-servlet-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at com.xwood.basic.papp.protocol.jetty.JettyResourceFilter.doFilter(JettyResourceFilter.java:73) [papp-5.2.6.jar:5.2.6]@b@	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1467) [jetty-servlet-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501) [jetty-servlet-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:229) [jetty-server-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086) [jetty-server-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429) [jetty-servlet-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193) [jetty-server-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020) [jetty-server-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135) [jetty-server-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) [jetty-server-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.server.Server.handle(Server.java:370) [jetty-server-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494) [jetty-server-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971) [jetty-server-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033) [jetty-server-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644) [jetty-http-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235) [jetty-http-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) [jetty-server-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696) [jetty-io-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53) [jetty-io-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) [jetty-util-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) [jetty-util-8.1.16.v20140903-8.1.16.jar:8.1.16.v20140903]@b@	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_11]@b@Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.xwood.pms.dto.ldsp.dto.UserDTO@b@	at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:818) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	at org.apache.ibatis.session.Configuration.getResultMap(Configuration.java:570) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	at org.apache.ibatis.builder.MapperBuilderAssistant.setStatementResultMap(MapperBuilderAssistant.java:356) ~[mybatis-3.3.0-3.3.0.jar:3.3.0]@b@	... 81 more

对应的UserMapper.xml配置如下

<?xml version="1.0" encoding="UTF-8" ?>  @b@<!DOCTYPE mapper   @b@  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"   @b@  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">@b@<mapper namespace="com.xwood.pms.dto.UserDAO">@b@@b@	<!-- 获取分页列表 -->@b@	<select id="getPageList" resultMap="com.xwood.pms.dto.UserDTO"@b@		parameterType="java.util.Map">@b@		SELECT@b@			PG.* FROM (@b@		SELECT@b@			G.*,ROWNUM RN FROM@b@		(SELECT@b@			ID id,@b@			USER_NAME userName,@b@			PASSWORD password,@b@			LOGIN_TIMES loginTimes, @b@			CREATED_BY,@b@			TO_DATE(TO_CHAR(UPDATED_DATE,'YYYY-MM-DD'),'YYYY-MM-DD') UPDATED_DATE  @b@		FROM T_USER@b@		WHERE 1=1 AND DATA_STATUS ='1' @b@		ORDER BY UPDATED_DATE Desc) G ) PG Where PG.rn &lt;= #{endNum} AND PG.rn &gt; #{startNum}@b@	</select>@b@	@b@</mapper>

二、解决方法

修改UserMapper.xml配置中resultMap为resultType问题解决了,如下所示

<?xml version="1.0" encoding="UTF-8" ?>  @b@<!DOCTYPE mapper   @b@  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"   @b@  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">@b@<mapper namespace="com.xwood.pms.dto.UserDAO">@b@@b@	<!-- 获取分页列表 -->@b@	<select id="getPageList" resultType="com.xwood.pms.dto.UserDTO"@b@		parameterType="java.util.Map">@b@		SELECT@b@			PG.* FROM (@b@		SELECT@b@			G.*,ROWNUM RN FROM@b@		(SELECT@b@			ID id,@b@			USER_NAME userName,@b@			PASSWORD password,@b@			LOGIN_TIMES loginTimes, @b@			CREATED_BY,@b@			TO_DATE(TO_CHAR(UPDATED_DATE,'YYYY-MM-DD'),'YYYY-MM-DD') UPDATED_DATE  @b@		FROM T_USER@b@		WHERE 1=1 AND DATA_STATUS ='1' @b@		ORDER BY UPDATED_DATE Desc) G ) PG Where PG.rn &lt;= #{endNum} AND PG.rn &gt; #{startNum}@b@	</select>@b@	@b@</mapper>
<<热门下载>>