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

具体错误信息:

  1. 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
  2. at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
  3. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
  4. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
  5. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
  6. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
  7. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
  8. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  9. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
  10. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
  11. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
  12. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
  13. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
  14. at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
  15. at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
  16. at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
  1. Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.mkit.task.manager.dao.ScheduleJobMapper.getAll
  2. at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
  3. at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43)
  4. at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
  5. at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
  6. at com.sun.proxy.$Proxy19.getAll(Unknown Source)
  7. at com.mkit.task.manager.service.impl.JobTaskServiceImpl.init(JobTaskServiceImpl.java:154)
  8. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  9. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  10. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  11. at java.lang.reflect.Method.invoke(Method.java:606)
  12. at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:349)
  13. at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:300)
  14. at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:133)
  15. ... 61 more

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

解决:

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

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

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

  1. <mapper namespace="com.mkit.task.manager.dao.ScheduleJobMapper">
  2. <resultMap id="BaseResultMap" type="com.mkit.task.manager.pojo.ScheduleJob">
  3. <id column="job_id" property="jobId" jdbcType="BIGINT" />
  4. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  5. <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
  6. <result column="job_name" property="jobName" jdbcType="VARCHAR" />
  7. <result column="job_group" property="jobGroup" jdbcType="VARCHAR" />
  8. <result column="job_status" property="jobStatus" jdbcType="VARCHAR" />
  9. <result column="cron_expression" property="cronExpression"
  10. jdbcType="VARCHAR" />
  11. <result column="description" property="description" jdbcType="VARCHAR" />
  12. <result column="bean_class" property="beanClass" jdbcType="VARCHAR" />
  13. <result column="is_concurrent" property="isConcurrent"
  14. jdbcType="VARCHAR" />
  15. <result column="spring_id" property="springId" jdbcType="VARCHAR" />
  16. <result column="method_name" property="methodName" jdbcType="VARCHAR" />
  17. </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. LU分解(2)

    接着上次LU分解的讲解,这次给出使用不同的计算LU分解的方法,这种方法称为基于GaxPy的计算方法.这里需要了解lapapck中的一些函数.lapack中有一个函数名为gaxpy,所对应的矩阵计算公式 ...

  2. .net 安装remoting服务

    程序->vs2008->vs tools->vs2008 命令提示 D:\QidianWorkShop\Develop\Source\Services\Snda.Qidian.Hon ...

  3. 自定义H5页面规范

    查看详情页也可支持自定义H5页面,用来展示更多内容. 交互规范 分屏切换,支持横向和竖向,滑动指引需清晰 若详情页加载较慢,需设计loading页,给予用户友好的提示 如有视频,需在底部加上“建议在W ...

  4. linux怎么给一个普通用户reboot权限?

    分四种情况讨论:1.让任何人(包括根本不拥有系统帐号的人)都可以通过控制台reboot在/etc/inittab文件中保留ca::ctrlaltdel:/sbin/shutdown -t3 -r no ...

  5. 【iOS】Resumable Doanloads(断点下载)

    这里我们只讨论iOS平台下的通用app,我们可以自己写代码来实现resume downloads,解释如下. resume一个HTTP下载不难,但必须要理解一些关键的HTTP概念: entity ta ...

  6. noip 2009 道路游戏

    /*10分钟的暴力 意料之中的5分..*/ #include<iostream> #include<cstdio> #include<cstring> #defin ...

  7. CSS 之 margin知识点

    1.margin的百分比值 普通元素的百分比maigin相对于容器元素的宽度(width) 进行计算的. 这里我们在图片外面设置一个宽高分别为800 * 600的容器.设置img{ margin: 1 ...

  8. python中关于list列表的增删查改操作

    python中list的操#python创建列表的时候,会以堆栈的形式存放数据,从右向左往堆栈中存放数据 movies=["The holy Grail","The li ...

  9. android 瀑布流(图片浏览)

    效果图: 瀑流流实现涉及的知识点 1.ScrollView滚动视图,我们这里用的是自定义ScrollView /** * Created by Spring on 2015/11/2. * 自定义Sc ...

  10. msi软件包无法安装

    安装某些msi软件包,提示“This advertised application will not be installed because it might be unsafe. Contact ...