mybatis常见错误汇总

时间:2022-09-17 10:07:48

1、Result Maps collection does not contain value for 

Caused by: org.apache.ibatis.builder.IncompleteElementException: Could not find result map com.business.entity.RepayChannel
at org.apache.ibatis.builder.MapperBuilderAssistant.setStatementResultMap(MapperBuilderAssistant.java:346)
at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:284)
at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:107)
at org.apache.ibatis.session.Configuration.buildAllStatements(Configuration.java:698)
at org.apache.ibatis.session.Configuration.hasStatement(Configuration.java:668)
at org.apache.ibatis.session.Configuration.hasStatement(Configuration.java:663)
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:180)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
at com.sun.proxy.$Proxy29.selectResourcess(Unknown Source)
at com.cardniu.ccrepayment.service.system.impl.ResourcesServiceImpl.selectResourcess(ResourcesServiceImpl.java:99)
at com.cardniu.ccrepayment.service.system.impl.ResourcesServiceImpl$$FastClassBySpringCGLIB$$fd86be84.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.aspectj.AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:43)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
at com.cardniu.ccrepayment.service.system.impl.ResourcesServiceImpl$$EnhancerBySpringCGLIB$$2309954f.selectResourcess(<generated>)
at com.cardniu.ccrepayment.shiro.ChainDefinitionSectionMetaSource.getObject(ChainDefinitionSectionMetaSource.java:39)
at com.cardniu.ccrepayment.shiro.ChainDefinitionSectionMetaSource.getObject(ChainDefinitionSectionMetaSource.java:1)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
... 29 more
Caused by: java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.business.entity.RepayChannel
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:797)
at org.apache.ibatis.session.Configuration.getResultMap(Configuration.java:550)
at org.apache.ibatis.builder.MapperBuilderAssistant.setStatementResultMap(MapperBuilderAssistant.java:344)
... 55 more

原因:resultType写成resultMap

resultMap后面接mapper.xml定义的列集合,

resultType后面才能接具体的类

<select id="selectChannel" resultMap="com.business.entity.RepayChannel">