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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值