MyBatis:Parameter Maps collection does not contain value for 的问题解决

报错:

Java代码   收藏代码
  1. org.apache.ibatis.builder.xml.IncompleteStatementException: Could not find parameter map com.demo.sys.mapper.ModuleMapper.moduleMap  
  2.     at org.apache.ibatis.builder.MapperBuilderAssistant.setStatementParameterMap(MapperBuilderAssistant.java:256)  
  3.     at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:220)  
  4.     at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:66)  
  5.     at org.apache.ibatis.session.Configuration.buildAllStatements(Configuration.java:497)  
  6.     at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:434)  
  7.     at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:428)  
  8.     at org.apache.ibatis.binding.MapperMethod.setupCommandType(MapperMethod.java:188)  
  9.     at org.apache.ibatis.binding.MapperMethod.(MapperMethod.java:51)  
  10.     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:37)  
  11.     at $Proxy7.query(Unknown Source)  
  12.     at com.demo.sys.service.impl.UserServiceImpl.query(UserServiceImpl.java:56)  
  13.     at com.demo.sys.service.impl.UserServiceImpl.login(UserServiceImpl.java:81)  
  14.     at com.demo.sys.action.UserAction.login(UserAction.java:56)  
  15.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
  16.     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)  
  17.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
  18.     at java.lang.reflect.Method.invoke(Unknown Source)  
  19.     at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)  
  20.     at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)  
  21.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)  
  22.     at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)  
  23.     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)  
  24.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  25.     at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)  
  26.     at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)  
  27.     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)  
  28.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  29.     at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)  
  30.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  31.     at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)  
  32.     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)  
  33.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  34.     at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)  
  35.     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)  
  36.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  37.     at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)  
  38.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  39.     at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)  
  40.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  41.     at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)  
  42.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  43.     at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)  
  44.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  45.     at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)  
  46.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  47.     at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)  
  48.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  49.     at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:270)  
  50.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  51.     at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)  
  52.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  53.     at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)  
  54.     at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)  
  55.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  56.     at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)  
  57.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  58.     at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)  
  59.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  60.     at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)  
  61.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  62.     at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)  
  63.     at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)  
  64.     at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)  
  65.     at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)  
  66.     at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)  
  67.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)  
  68.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)  
  69.     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)  
  70.     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)  
  71.     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)  
  72.     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)  
  73.     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)  
  74.     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)  
  75.     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)  
  76.     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)  
  77.     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)  
  78.     at java.lang.Thread.run(Unknown Source)  
  79. Caused by: java.lang.IllegalArgumentException: Parameter Maps collection does not contain value for com.demo.sys.mapper.ModuleMapper.moduleMap  
  80.     at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:594)  
  81.     at org.apache.ibatis.session.Configuration.getParameterMap(Configuration.java:390)  
  82.     at org.apache.ibatis.builder.MapperBuilderAssistant.setStatementParameterMap(MapperBuilderAssistant.java:254)  
  83.     ... 76 more  

 

 

发现配置:

Java代码   收藏代码
  1. "com.demo.sys.entity.Module" id="moduleMap">  
  2.     "id" column="id" />  
  3.     "name" column="name" />  
  4.     "remark" column="remark" />  
  5.     "createDate" column="createdate" />  
  6.     "updateDate" column="updateDate" />  
  7.     "parent" column="parent_id"  
  8.         resultMap="moduleMap" select="queryModule">  
  9.       
  10.     "childs" column="parent_id"  
  11.         javaType="ArrayList" ofType="com.demo.sys.entity.Module"  
  12.         select="queryChildList">  
  13.       
  14.   
  15. "queryList" parameterMap="moduleMap" resultMap="moduleMap">  
  16.     select * from sys_module where id =#{id}  
  17.   

 

更改配置:

 

Java代码   收藏代码
  1. "com.demo.sys.entity.Module" id="moduleMap">  
  2.         "id" column="id" />  
  3.         "name" column="name" />  
  4.         "remark" column="remark" />  
  5.         "createDate" column="createdate" />  
  6.         "updateDate" column="updateDate" />  
  7.         "parent" column="parent_id"  
  8.             resultMap="moduleMap" select="queryModule">  
  9.           
  10.         "childs" column="parent_id"  
  11.             javaType="ArrayList" ofType="com.demo.sys.entity.Module"  
  12.             select="queryChildList">  
  13.           
  14.       
  15.     "queryList"  parameterType="com.demo.sys.entity.Module" resultMap="moduleMap">  
  16.         select * from sys_module where id =#{id}  
  17.       

 

 

parameterMap="moduleMap" -------》parameterType="com.demo.sys.entity.Module"

 

解决了Mybatis中Parameter Maps collection does not contain value for xxx 的问题了。

 

查看Mybatis官方资料:

SQL映射的XML文件:parameterMap 已经废弃了,现在使用parameterType来处理。

你可能感兴趣的:(MyBatis)