Mapped Statements collection does not contain value

超、凢脫俗 2022-03-26 04:48 237阅读 0赞

最近一个项目在启动的时候,当需要访问service时,报错了,出现如下错误:

分析:我们的service不应该跟mybatis有什么关系,而异常中说我们的servcie不符合mybatis的映射规则。

所以应该是spring和mybatis整合的时候,把我们的service也当成普通的mapper扫描进去了。

核查配置文件发现(改配置扫描了项目上所有的包,需要缩小范围):

  1. <!-- spring与mybatis整合配置,扫描所有dao -->
  2. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer" p:basePackage="com.xxx.newportal."
  3. p:sqlSessionFactoryBeanName="sqlSessionFactory"/>

改为如下即可

  1. <!-- spring与mybatis整合配置,扫描所有dao -->
  2. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer" p:basePackage="com.xxxx.newportal.certtrustweb.dao"
  3. p:sqlSessionFactoryBeanName="sqlSessionFactory"/>
  4. 严重: Servlet.service() for servlet [dispatcher] in context with path [/certtrustweb] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.xxx.xxx.certtrustweb.service.MakeCertService.makeCertByFisrtTime] with root cause
  5. java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.xxxx.certtrustweb.service.MakeCertService.makeCertByFisrtTime
  6. at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:775)
  7. at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:615)
  8. at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:608)
  9. at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:176)
  10. at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:38)
  11. at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:49)
  12. at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:42)
  13. at com.sun.proxy.$Proxy29.makeCertByFisrtTime(Unknown Source)

发表评论

表情:
评论列表 (有 0 条评论,237人围观)

还没有评论,来说两句吧...

相关阅读