Result Maps collection does not contain value for

1、
在进行SS+mybatis结合的时候 经常会遇到这样的错误(Mapped Statements collection does not contain value for...

从字面上的意思很难理解和定位是哪里出错了, 经过不探索果然功夫不负有心人,其实是命名空间引入错了

正确的引入应该把类名给引入进来 如下:

[html]  view plain copy
  1. <?xml version="1.0" encoding="UTF-8" ?>    
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">   
  3. <mapper namespace="com.mochasoft.proscenium.dao.AutocompleteDao">  
  4.     <resultMap type="searchHistory" id="searchHistoryMap">  
  5.         <result column="word" property="word"/>  
  6.         <result column="search_count" property="seachCount"/>  
  7.     </resultMap>  
  8.     <select id="getSearchHistoryByTerm" resultMap="searchHistoryMap" parameterType="String">  
  9.        select word, search_count  
  10.         from v_search_history  
  11.         where word like #{term}  
  12.         order by search_count  
  13.     </select>  
  14. </mapper>  


这样它就会寻找com.mochasoft.proscenium.dao.AutocompleteDao类下面的getSearchHistoryByTerm方法 


2、

    还有一种跟这个类似的错误:Result Maps collection does not contain value for。。。

出现这个错误 主要是因为你的select标签内部的resultMap属性 指向的不正确

猜你喜欢

转载自blog.csdn.net/qq_35193093/article/details/80333742