title: Result Maps collection does not contain value error while ResultMap.xml to @Mapper class
body: <p>I am trying to bind the result of the query (inside @Mapper class and using @Select annotation for the query) to a Mapper.xml as I have a pretty complex POJO to map to.</p>
  
  <p>Here is my code:  </p>
  
  <p><strong>MapMapper.class :</strong></p>
  
  <pre><code>@Mapper
  public interface MapMapper {
  
      @Select("select seat_id,row_pos,column_pos,is_assigned,team_id,map_id from t002_seat_mst where map_id=#{mapId}")
      @ResultMap("SeatsResultMap")
      MapDTO fetchMapSeatsByIdWhenNoTeam(int mapId);
  
  }
  </code></pre>
  
  <p><strong>SeatsMapper.xml :</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"&gt;
  &lt;mapper namespace="com.seat.arrangement.dao.mapper.MapMapper"&gt;
      &lt;resultMap id="SeatsResultMap" type="com.seat.arrangement.model.MapDTO"&gt;
          &lt;result column="map_id" jdbcType="NUMERIC" property="mapId" /&gt;
          &lt;collection property="seats" ofType="com.seat.arrangement.model.SeatDTO"&gt;
              &lt;result property="seatId" column="seat_id" /&gt;
              &lt;result property="rowNumber" column="row_pos" /&gt;
              &lt;result property="columnNumber" column="column_pos" /&gt;
              &lt;result property="isAssigned" column="is_assigned" /&gt;
              &lt;result property="team.teamId" column="team_id" /&gt;
          &lt;/collection&gt;
      &lt;/resultMap&gt;
  &lt;/mapper&gt;  
  </code></pre>
  
  <p><strong>Error log :</strong></p>
  
  <pre><code>java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.seat.arrangement.dao.mapper.MapMapper.SeatsResultMap
      at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:964) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.session.Configuration.getResultMap(Configuration.java:674) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.builder.MapperBuilderAssistant.getStatementResultMaps(MapperBuilderAssistant.java:339) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:285) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.parseStatement(MapperAnnotationBuilder.java:358) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.builder.annotation.MethodResolver.resolve(MethodResolver.java:33) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.session.Configuration.lambda$buildAllStatements$3(Configuration.java:824) ~[mybatis-3.5.3.jar:3.5.3]
      at java.base/java.util.Collection.removeIf(Collection.java:544) ~[na:na]
      at org.apache.ibatis.session.Configuration.buildAllStatements(Configuration.java:823) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.session.Configuration.hasStatement(Configuration.java:792) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.session.Configuration.hasStatement(Configuration.java:787) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.binding.MapperMethod$SqlCommand.resolveMappedStatement(MapperMethod.java:257) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.binding.MapperMethod$SqlCommand.&lt;init&gt;(MapperMethod.java:227) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.binding.MapperMethod.&lt;init&gt;(MapperMethod.java:53) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.binding.MapperProxy.lambda$cachedMapperMethod$0(MapperProxy.java:98) ~[mybatis-3.5.3.jar:3.5.3]
      at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705) ~[na:na]
      at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:97) ~[mybatis-3.5.3.jar:3.5.3]
      at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:92) ~[mybatis-3.5.3.jar:3.5.3]
      at com.sun.proxy.$Proxy74.fetchAllTeams(Unknown Source) ~[na:na]
      at com.seat.arrangement.dao.impl.FetchMapsDaoImpl.fetchAllTeams(FetchMapsDaoImpl.java:32) ~[classes/:na]
      at com.seat.arrangement.service.impl.FetchMapServiceImpl.fetchAllTeams(FetchMapServiceImpl.java:32) ~[classes/:na]
      at com.seat.arrangement.rest.SeatingArrangementController.fetchAllTeams(SeatingArrangementController.java:33) ~[classes/:na]
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
      at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
      at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.27.jar:9.0.27]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
      at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.27.jar:9.0.27]
      at java.base/java.lang.Thread.run(Thread.java:830) ~[na:na]
  </code></pre>
  
  <p>I do have a <code>mybatis-config.xml</code> file inside <code>resources/config/mybatis-config.xml</code></p>
  
  <p><strong>mybatis-config.xml :</strong> </p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;!DOCTYPE configuration
          PUBLIC '-//mybatis.org//DTD Config 3.0//EN'
          'http://mybatis.org/dtd/mybatis-3-config.dtd'&gt;
  &lt;!--&lt;!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Confi 3.0//EN"
          "config//mybatis-3-config.dtd"&gt;--&gt;
  &lt;configuration&gt;
  
      &lt;mappers&gt;
          &lt;mapper resource='config/SeatsMapper.xml'/&gt;
      &lt;/mappers&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Since I am provide jdbc properties from the <code>application.properties</code> file, I have only used <code>&lt;mappers&gt;&lt;/mappers&gt;</code> in <code>mybatis-config.xml</code>. Is it wrong?   </p>
  
  <p><strong>Here is my application.properties file :</strong> </p>
  
  <pre><code>server.port=7777
  
  spring.datasource.url=jdbc:mysql://localhost:3306/test
  spring.datasource.username=root
  spring.datasource.password=root
  spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  spring.datasource.testWhileIdle=true
  spring.datasource.validationQuery=SELECT 1
  
  mybatis.config=classpath:config//mybatis-config.xml  
  </code></pre>
  
  <p>Can anyone help me where I am going wrong?
  Thank you.</p>