Mapped Statements collection does not contain value
最近一个项目在启动的时候,当需要访问service时,报错了,出现如下错误:
分析:我们的service不应该跟mybatis有什么关系,而异常中说我们的servcie不符合mybatis的映射规则。
所以应该是spring和mybatis整合的时候,把我们的service也当成普通的mapper扫描进去了。
核查配置文件发现(改配置扫描了项目上所有的包,需要缩小范围):
<!-- spring与mybatis整合配置,扫描所有dao -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer" p:basePackage="com.xxx.newportal."
p:sqlSessionFactoryBeanName="sqlSessionFactory"/>
改为如下即可
<!-- spring与mybatis整合配置,扫描所有dao -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer" p:basePackage="com.xxxx.newportal.certtrustweb.dao"
p:sqlSessionFactoryBeanName="sqlSessionFactory"/>
严重: 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
java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.xxxx.certtrustweb.service.MakeCertService.makeCertByFisrtTime
at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:775)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:615)
at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:608)
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:176)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:38)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:49)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:42)
at com.sun.proxy.$Proxy29.makeCertByFisrtTime(Unknown Source)
还没有评论,来说两句吧...