今天在开发项目的时候使用MyBatis发生错误:Invalid bound statement (not found)

具体错误信息:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobTaskServiceImpl': Invocation of init method failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.mkit.task.manager.dao.ScheduleJobMapper.getAll
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.mkit.task.manager.dao.ScheduleJobMapper.getAll
    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
    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.$Proxy19.getAll(Unknown Source)
    at com.mkit.task.manager.service.impl.JobTaskServiceImpl.init(JobTaskServiceImpl.java:154)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
    ... 61 more

通过分析找到了问题的原因。我出现这个错误的主要原因是因为dao层和Mapper.xml是从别的项目中copy过来的,然后这些属性值都没有做更改,所以报这样的错误。

解决:

1.首先查看spring-mybatis.xml文件中,对于dao层的class扫描路径是否正确。

2.检查Mapper.xml文件中namespace属性值是否正确

3.检查Mapper.xml文件中resultMap中type属性值是否正确

<mapper namespace="com.mkit.task.manager.dao.ScheduleJobMapper">
    <resultMap id="BaseResultMap" type="com.mkit.task.manager.pojo.ScheduleJob">
        <id column="job_id" property="jobId" jdbcType="BIGINT" />
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="job_name" property="jobName" jdbcType="VARCHAR" />
        <result column="job_group" property="jobGroup" jdbcType="VARCHAR" />
        <result column="job_status" property="jobStatus" jdbcType="VARCHAR" />
        <result column="cron_expression" property="cronExpression"
            jdbcType="VARCHAR" />
        <result column="description" property="description" jdbcType="VARCHAR" />
        <result column="bean_class" property="beanClass" jdbcType="VARCHAR" />
        <result column="is_concurrent" property="isConcurrent"
            jdbcType="VARCHAR" />
        <result column="spring_id" property="springId" jdbcType="VARCHAR" />
        <result column="method_name" property="methodName" jdbcType="VARCHAR" />
    </resultMap>

MyBatis错误--Invalid bound statement (not found)的更多相关文章

  1. mybatis错误Invalid bound statement (not found) 的解决办法

    <!-- IDEA需要添加一下内容,否则无法找到mapper --> <build> <resources> <resource> <direct ...

  2. MyBatis绑定错误[Invalid bound statement (not found)]

    如果出现: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 一般的原因是Mapper i ...

  3. myBatis中Invalid bound statement (not found)错误

    环境:Idea.ssm.maven 由于使用maven的原因,maven不会扫描到mapper的xml文件所以会出现此类问题. 每次走到mapper方法时就抛异常:Invalid bound stat ...

  4. mybatis:Invalid bound statement (not found)

    [常规解决办法] 如果出现: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 一般的原因 ...

  5. mybatis 报Invalid bound statement(not found) 和 Property 'mapperLocations' was not specified or not matching resources found

    排除问题的步骤: 1.首先检查mapper文件和mapper接口的文件名是否相等. 2.pom.xml是否把xml排除了,这样写就会src/main/java下所有的Mybatis的xml文件都删除, ...

  6. 解决Mybatis的invalid bound statement (not found)异常

    使用Maven构建SSM时, 需要在pom.xml中配置一些信息, 否则mapper.xml就无法被扫描到, 程序就会抛invalid bound statement (not found)异常 解决 ...

  7. 关于 Mybatis 的Invalid bound statement (not found):错误

    今天遇到一个特别奇怪的问题,最后发现是自己对mybatis的学习还有待提高 返回类型可以用resultType,也可以用resultMap resultType是直接表示返回类型的,而resultMa ...

  8. mybatis提示Invalid bound statement (not found)错误的可能原因

    https://www.cnblogs.com/liaojie970/p/8034525.html

  9. mybatis BindingException: Invalid bound statement (not found)

    错误截图 解决措施 此异常的原因是由于mapper接口编译后在同一个目录下没有找到mapper映射文件而出现的. 通常我们在配置SqlSessionFactory时会有如配置 <!-- 配置Sq ...

随机推荐

  1. 自己动手学TCP/IP–http协议(http报文头)

    在前面的一篇文章中,简单了介绍了HTTP报文格式,详情参考http://www.firefoxbug.net/?cat=47. 这里大概介绍下基本的,常见的HTTP包头格式. POST /report ...

  2. (转载)Python 列表(list)操作

    (转载)http://blog.csdn.net/facevoid/article/details/5338048 创建列表sample_list = ['a',1,('a','b')] Python ...

  3. 【贪心】XMU 1061 Ckp的约会

    题目链接: http://acm.xmu.edu.cn/JudgeOnline/problem.php?id=1061 题目大意: n个任务(n<=1000),给定名字和开始.结束时间,求最多能 ...

  4. casperjs配合phantomjs实现自动登录百度,模拟点击等等操作 - 怕虎在线www.ipahoo.com图文教程 - 怕虎在线

    微信支付取消2万元保证金门槛,这是全民电商来袭!-观点-虎嗅网 微信支付取消2万元保证金门槛,这是全民电商来袭! casperjs配合phantomjs实现自动登录百度,模拟点击等等操作 - 怕虎在线 ...

  5. Java高级特性之枚举学习总结

    在Java SE5之前,我们要使用枚举类型时,通常会使用static final 定义一组int常量来标识,代码如下 public static final int MAN = 0; public s ...

  6. webservice2-wsimport的使用

    打开Eclipse,新建java项目,service_start cmd下运行wsimport(要配置jdk的环境变量,wsimport在JAVA_HOME/bin下) wsimport -d d:/ ...

  7. java:利用数组实现将古诗词纵向输出

      java:利用二维数组实现将古诗词纵向输出. 从网络上随便搜索一首古诗词,这里刻意选择句子长短不一的诗词 1.首先先把诗词放进一个二维数组中. 这里将数组类型定义成char 类型,因为将其定义为S ...

  8. Object-C变量作用域 -- 笔记

    @interface Dog: NSObject { @public int age; @protected int ID; @Private float price; } @end 字段作用域解析: ...

  9. EMV/PBOC 解析(一) 卡片文件结构

    刚到公司老大便发我一份文档<智能卡ISO7816-4规范(中文版)>,然后就让我研究下IC智能卡数据读取和支付.身为一直做.NET开发的我对硬件啥的一无所知,各种无头绪啊,研究了两天后,稍 ...

  10. SecureCRT连接vm中的ubuntu

    如何使用SecureCRT连接ubuntu 用secureCRT连接Ubuntu是出现远程系统拒绝访问..经过一翻研究才知道Ubuntu上没有ssh.. 一下为连接过程. 1. 首先要明白什么是ssh ...