MyBatis中出现Mapped Statements collection does not contain value异常解决方案
2015-01-28 13:13
471 查看
在使用MyBatis实现数据持久层过程中,定义了如下一个<select>
[html]
view plaincopyprint?
<?xml
version="1.0"
encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="com.talkweb.mapper.lead.LeadKPIDataMapper">
<resultMap
type="com.talkweb.domains.lead.KPIDataVO"
id="res_kpiDataVO">
<result
property="tagId"
column="TAG_ID"/>
<result
property="tagName"
column="CAL_NAME"/>
<result
property="tagValue"
column="TAG_VALUE"/>
<result
property="tagl1mValue"
column="TAG_L1M_VALUE"/>
<result
property="tagl1yValue"
column="TAG_L1Y_VALUE"/>
<result
property="risL1mRat"
column="RIS_L1M_RAT"/>
<result
property="risL1yRat"
column="RIS_L1Y_RAT"/>
<result
property="tagNameTip"
column="CAL_BUS_DESC"/>
<result
property="date"
column="TIME_ID"/>
<result
property="areaId"
column="AREA_ID"/>
<result
property="cntyId"
column="CNTY_ID"/>
<result
property="townId"
column="TOWN_ID"/>
</resultMap>
<select
id="findKPIData"
resultMap="res_kpiDataVO">
SELECT K.TAG_ID,T.CAL_NAME FROM SHW.RPT_MN_TAG_DFLT_FEE_MM AS K INNER JOIN WI.MN_CAL_LIST_DST AS T
[html]
view plaincopyprint?
ON K.TAG_ID=T.TAG_ID AND
K.TIME_ID=20120515 AND
K.CNTY_ID='E398' WITH UR
</select>
</mapper>
对应的接口文件为LeadKPIDataMapper .java:
[java]
view plaincopyprint?
public interface LeadKPIDataMapper {
public List<KPIDataVO> findKPIData();
}
在测试过程中,系统总是出现如下异常:
java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.talkweb.mapper.lead.LeadKPIDataMapper.findKPIData
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:594)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:436)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:428)
at org.apache.ibatis.binding.MapperMethod.setupCommandType(MapperMethod.java:188)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:51)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:37)
经过排查,解决上述异常的过程如下:
1.确定xml文件中<mapper namespace=""/>中的namespace是否路径正确(在此案例中namespace与实际路径一致),由于namespace不同会引发此问题
2.确定xml文件的名称是否与接口类的名称保持一致,在上例中出现问题就是因为不小心将xml文件命名为LendKPIDataMapper.xml,而接口文件为:LeadKPIDataMapper.java。一字之差导致异常的发生。
总结:细心,仔细,认真是程序开发之根本。
【原文:http://blog.csdn.net/wikiwang/article/details/7571108】
[html]
view plaincopyprint?
<?xml
version="1.0"
encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="com.talkweb.mapper.lead.LeadKPIDataMapper">
<resultMap
type="com.talkweb.domains.lead.KPIDataVO"
id="res_kpiDataVO">
<result
property="tagId"
column="TAG_ID"/>
<result
property="tagName"
column="CAL_NAME"/>
<result
property="tagValue"
column="TAG_VALUE"/>
<result
property="tagl1mValue"
column="TAG_L1M_VALUE"/>
<result
property="tagl1yValue"
column="TAG_L1Y_VALUE"/>
<result
property="risL1mRat"
column="RIS_L1M_RAT"/>
<result
property="risL1yRat"
column="RIS_L1Y_RAT"/>
<result
property="tagNameTip"
column="CAL_BUS_DESC"/>
<result
property="date"
column="TIME_ID"/>
<result
property="areaId"
column="AREA_ID"/>
<result
property="cntyId"
column="CNTY_ID"/>
<result
property="townId"
column="TOWN_ID"/>
</resultMap>
<select
id="findKPIData"
resultMap="res_kpiDataVO">
SELECT K.TAG_ID,T.CAL_NAME FROM SHW.RPT_MN_TAG_DFLT_FEE_MM AS K INNER JOIN WI.MN_CAL_LIST_DST AS T
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.talkweb.mapper.lead.LeadKPIDataMapper"> <resultMap type="com.talkweb.domains.lead.KPIDataVO" id="res_kpiDataVO"> <result property="tagId" column="TAG_ID"/> <result property="tagName" column="CAL_NAME"/> <result property="tagValue" column="TAG_VALUE"/> <result property="tagl1mValue" column="TAG_L1M_VALUE"/> <result property="tagl1yValue" column="TAG_L1Y_VALUE"/> <result property="risL1mRat" column="RIS_L1M_RAT"/> <result property="risL1yRat" column="RIS_L1Y_RAT"/> <result property="tagNameTip" column="CAL_BUS_DESC"/> <result property="date" column="TIME_ID"/> <result property="areaId" column="AREA_ID"/> <result property="cntyId" column="CNTY_ID"/> <result property="townId" column="TOWN_ID"/> </resultMap> <select id="findKPIData" resultMap="res_kpiDataVO"> SELECT K.TAG_ID,T.CAL_NAME FROM SHW.RPT_MN_TAG_DFLT_FEE_MM AS K INNER JOIN WI.MN_CAL_LIST_DST AS T
[html]
view plaincopyprint?
ON K.TAG_ID=T.TAG_ID AND
K.TIME_ID=20120515 AND
K.CNTY_ID='E398' WITH UR
</select>
</mapper>
ON K.TAG_ID=T.TAG_ID AND K.TIME_ID=20120515 AND K.CNTY_ID='E398' WITH UR </select> </mapper>
对应的接口文件为LeadKPIDataMapper .java:
[java]
view plaincopyprint?
public interface LeadKPIDataMapper {
public List<KPIDataVO> findKPIData();
}
public interface LeadKPIDataMapper { public List<KPIDataVO> findKPIData(); }
在测试过程中,系统总是出现如下异常:
java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.talkweb.mapper.lead.LeadKPIDataMapper.findKPIData
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:594)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:436)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:428)
at org.apache.ibatis.binding.MapperMethod.setupCommandType(MapperMethod.java:188)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:51)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:37)
经过排查,解决上述异常的过程如下:
1.确定xml文件中<mapper namespace=""/>中的namespace是否路径正确(在此案例中namespace与实际路径一致),由于namespace不同会引发此问题
2.确定xml文件的名称是否与接口类的名称保持一致,在上例中出现问题就是因为不小心将xml文件命名为LendKPIDataMapper.xml,而接口文件为:LeadKPIDataMapper.java。一字之差导致异常的发生。
总结:细心,仔细,认真是程序开发之根本。
【原文:http://blog.csdn.net/wikiwang/article/details/7571108】
相关文章推荐
- MyBatis中出现Mapped Statements collection does not contain value异常解决方案
- MyBatis中出现Mapped Statements collection does not contain value 问题
- mybatis+springMVC整合出现Mapped Statements collection does not contain value for ***
- MyBatis出现java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for
- mybatis 抛出 Mapped Statements collection does not contain value for 异常
- mybatis+spring MVC启动的时候 4000 出现Mapped Statements collection does not contain value for
- 异常:使用mybatis框架 Mapped Statements collection does not contain value for 后面为类方法
- MyBatis中出现Mapped Statements collection does not contain value
- Mybatis 出现Mapped Statements collection does not contain value for xxx
- MyBatis中出现Mapped Statements collection does not contain value
- 【Mybatis】Mapped Statements collection does not contain value for的解决方案
- MyBatis异常java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for
- mybatis:java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for
- mybatis 错误 Mapped Statements collection does not contain value for
- myBatis配置报Mapped Statements collection does not contain value for
- mybatis错误 Mapped Statements collection does not contain value for
- mybatis之Mapped Statements collection does not contain value for...错误原因分析
- Mapped Statements collection does not contain value for 之运行异常原因
- 【Mybatis】java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for
- mybatis错误 Mapped Statements collection does not contain value for