MyBatis错误:Mapped Statements collection does not contain value for

roc99999999 2012-12-06 11:36:23
java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for uk.co.argylesoftware.erf.framework.zmoa.persistence.FinanceDOMapper.getFinances
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:593)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:393)
at org.apache.ibatis.binding.MapperMethod.setupCommandType(MapperMethod.java:160)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:37)
at $Proxy75.getFinances(Unknown Source)
at uk.co.argylesoftware.erf.framework.zmoa.services.impl.FinanceServiceMgrImpl.getFinances(FinanceServiceMgrImpl.java:77)
at uk.co.argylesoftware.erf.framework.zmoa.services.impl.FinanceServiceMgrImplTest.testGetFinances(FinanceServiceMgrImplTest.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:44)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
看了网上许多解决办法 ,但是都没有解决,望高人指点
...全文
55719 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
http://blog.csdn.net/zkn_cs_dn_2013/article/details/48007781 给你个链接看看。。。。。。。。。。。。。。。。
ztwsl888 2014-11-18
  • 打赏
  • 举报
回复
在applicationContext.xml中的<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> 中加入 <property name="mapperLocations" value="classpath:dao/*Mapper.xml" />
bruce_yuan1982 2014-09-23
  • 打赏
  • 举报
回复
好蠢....我查了半天知道了,我没把新加的xml文件,加入到项目的configuration.xml文件,也就是所谓的mybatis-config.xml总文件中,加入就正常了....
luckygirl3 2014-06-25
  • 打赏
  • 举报
回复
传入参数类型可能与xml中的不一致。
ailaopo415 2014-05-03
  • 打赏
  • 举报
回复
引用 11 楼 zhao2k9 的回复:
就是mybatis-config.xml配置文件的问题
看你的mybatis总文件中是否添加了你操作的文件。
u013563253 2014-01-26
  • 打赏
  • 举报
回复
mybatis-config.xml 文件的 mappar 顺序错误了。你要和上面的对应上。
zhao2k9 2013-12-12
  • 打赏
  • 举报
回复
就是mybatis-config.xml配置文件的问题
美工 2013-10-29
  • 打赏
  • 举报
回复
引用 9 楼 wayneliuok 的回复:
uk.co.argylesoftware.erf.framework.zmoa.persistence.FinanceDOMapper.getFinances 查找你这行 <mapper namespace="uk.co.argylesoftware.erf.framework.zmoa.persistence.FinanceDOMapper" > 在你的java文件里,还有这行 sqlSession.select(uk.co.argylesoftware.erf.framework.zmoa.persistence.FinanceDOMapper.getFinances); 你写的namespace肯定有不匹配的地方!
自己解决了还说解决方法 很给力 !比起楼主高出一大截
wayneliuok 2013-09-27
  • 打赏
  • 举报
回复
uk.co.argylesoftware.erf.framework.zmoa.persistence.FinanceDOMapper.getFinances 查找你这行 <mapper namespace="uk.co.argylesoftware.erf.framework.zmoa.persistence.FinanceDOMapper" > 在你的java文件里,还有这行 sqlSession.select(uk.co.argylesoftware.erf.framework.zmoa.persistence.FinanceDOMapper.getFinances); 你写的namespace肯定有不匹配的地方!
wangao1991 2013-08-23
  • 打赏
  • 举报
回复
引用 7 楼 pj1990zp 的回复:
mapper.xml文件路径和配置文件不匹配
能具体说明下吗,我也出现了这个错误,不过我之前运行好好的,运行了 mvn clean package -DskipTests 之后, 第二天打开就报这个错误了。
suciver 2012-12-06
  • 打赏
  • 举报
回复
从异常信息来看你Finances属性传了不正确的参数
roc99999999 2012-12-06
  • 打赏
  • 举报
回复
mapper.xml文件路径和配置文件不匹配
roc99999999 2012-12-06
  • 打赏
  • 举报
回复
网上说这种错误名称空间不匹配什么的但是不存在这个问题。参数我也对比了,上边是代码,麻烦帮我看下吧 ,本人菜鸟 ,真的很费解,困扰好久了
roc99999999 2012-12-06
  • 打赏
  • 举报
回复
这是Dao层接口 @Repository public interface FinanceDOMapper { List<FinanceDO> getFinances(@Param("year")Integer year,@Param("moneyAmount")Double moneyAmount,@Param("occurrenceDate")Date occurrenceDate, @Param("employee")String employee,@Param("type")Integer type,@Param("describe")String describe, RowBounds rb); } 这是Mapper.xml <?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="uk.co.argylesoftware.erf.framework.zmoa.persistence.FinanceDOMapper" > <resultMap id="BaseResultMap" type="uk.co.argylesoftware.erf.framework.zmoa.persistence.object.FinanceDO" > <id column="FINANCE_ID" property="financeId" jdbcType="BIGINT" /> <result column="PAY" property="pay" jdbcType="REAL" /> <result column="INCOME" property="income" jdbcType="REAL" /> <result column="OCCURRENCE_DATE" property="occurrenceDate" jdbcType="TIMESTAMP" /> <result column="INSERT_TIME" property="InsertTime" jdbcType="TIMESTAMP" /> <result column="UPDATE_TIME" property="UpdateTime" jdbcType="TIMESTAMP" /> <result column="EMPLOYEE_ID" property="employee" jdbcType="BIGINT" /> <result column="TYPE" property="type" jdbcType="INTEGER" /> <result column="DESCRIBES" property="describe" jdbcType="VARCHAR" /> </resultMap> <select id="getFinances" parameterType="map" resultMap="BaseResultMap"> <choose> <when test="year != null"> select * from zmoa_finance INNER JOIN zmoa_employee ON zmoa_finance.EMPLOYEE_ID=zmoa_employee.EmployeeId <where> <if test="employee != null"> <choose> <when test="moneyAmount != null"> (MONEYAMOUNT LIKE #{moneyAmount,jdbcType=REAL}"%" or EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%" or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) </when> <otherwise> (EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%" or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) </otherwise> </choose> </if> <if test="type != null"> and TYPE = #{type,jdbcType="INTEGER"} </if> and OCCURRENCE_DATE LIKE #{year,jdbcType=INTEGER}"%" </where> </when> <otherwise> select * from zmoa_finance INNER JOIN zmoa_employee ON zmoa_finance.EMPLOYEE_ID=zmoa_employee.EmployeeId <where> <if test="employee != null"> <choose> <when test="moneyAmount != null"> (MONEYAMOUNT LIKE #{moneyAmount,jdbcType=REAL}"%" or EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%" or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) </when> <otherwise> (EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%" or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) </otherwise> </choose> </if> <if test="type != null"> and TYPE = #{type,jdbcType="INTEGER"} </if> <if test="occurrenceDate"> and OCCURRENCE_DATE LIKE #{occurrenceDate,jdbcType=TIMESTAMP}"%" </if> </where> </otherwise> </choose> </select> </mapper>
suciver 2012-12-06
  • 打赏
  • 举报
回复
既然异常报这个出来。你就好好认真的比对下。
roc99999999 2012-12-06
  • 打赏
  • 举报
回复
没发现不正确的参数啊
roc99999999 2012-12-06
  • 打赏
  • 举报
回复
<select id="getFinances" parameterType="map" resultMap="BaseResultMap"> <choose> <when test="year != null"> select * from zmoa_finance INNER JOIN zmoa_employee ON zmoa_finance.EMPLOYEE_ID=zmoa_employee.EmployeeId <where> <if test="employee != null"> <choose> <when test="moneyAmount != null"> (MONEYAMOUNT LIKE #{moneyAmount,jdbcType=REAL}"%" or EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%" or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) </when> <otherwise> (EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%" or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) </otherwise> </choose> </if> <if test="type != null"> and TYPE = #{describe,jdbcType="INTEGER"} </if> and OCCURRENCE_DATE LIKE #{year,jdbcType=INTEGER}"%" </where> </when> <otherwise> select * from zmoa_finance INNER JOIN zmoa_employee ON zmoa_finance.EMPLOYEE_ID=zmoa_employee.EmployeeId <where> <if test="employee != null"> <choose> <when test="moneyAmount != null"> (MONEYAMOUNT LIKE #{moneyAmount,jdbcType=REAL}"%" or EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%" or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) </when> <otherwise> (EmployeeName LIKE #{employee,jdbcType="VARCHAR"}"%" or DESCRIBES LIKE #{describe,jdbcType="VARCHAR"}"%" ) </otherwise> </choose> </if> <if test="type != null"> and TYPE = #{describe,jdbcType="INTEGER"} </if> <if test="occurrenceDate"> and OCCURRENCE_DATE LIKE #{occurrenceDate,jdbcType=TIMESTAMP}"%" </if> </where> </otherwise> </choose> </select>

81,120

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧