在IntelliJ IDEA中用ssm框架搭建了一个demo项目,在执行到dao层方法时抛出这个异常:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.monolog.diana.dao.StatisticsDao.clear

第一反应是mapper的名称空间没有跟dao关联,或者dao的方法名和mapper的id不匹配。但是检查了一遍,没有这个问题。然后发现target目录下面并没有编译后的mapper文件。在网上搜了一下,有大神建议在pom文件的<build><resources></resources></build>标签下,将mapper的路径添加进去。类似于这样:

  1. <resource>
  2. <directory>src/main/java</directory>
  3. <includes>
  4. <include>**/*.xml</include>
  5. </includes>
  6. </resource>

大概思路就是编译的时候告诉maven哪些是配置文件。

另外还有一种方式,因为我的pom文件本来是这样的:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5. ...
  6.  
  7. <!--项目搭建-->
  8. <build>
  9. <!--打包用名-->
  10. <finalName>diana.web</finalName>
  11. <!--插件-->
  12. <plugins>
  13. <plugin>
  14. <groupId>org.apache.maven.plugins</groupId>
  15. <artifactId>maven-compiler-plugin</artifactId>
  16. </plugin>
  17. </plugins>
  18. <!--配置文件-->
  19. <resources>
  20. <resource>
  21. <directory>src/main/resources</directory>
  22. <filtering>true</filtering>
  23. </resource>
  24. </resources>
  25. </build>
  26. </project>

即已经指定了配置文件的位置:src/main/resources,那么我把mapper文件扔到resources目录下(而不是java目录下)就可以了,类似于这样:

ssm项目dao层方法异常:org.apache.ibatis.binding.BindingException: Invalid bound statement的更多相关文章

  1. 异常 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 解决方案

    原来是因为 AssetsMapper.xml 不知道为什么不见了,导致这个异常,在启动项目时的启动任务里调用到了它,然后因为没有这个xml,所以抛出异常 启动信息: C:\extend\Develop ...

  2. Spring扫面路径配置不全导致异常 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 的原因

    运行Junit测试类 package cn.bgodata.x.zero.service; import org.junit.Test; import org.junit.runner.RunWith ...

  3. Maven项目使用mybatis报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

    maven项目使用mybatis时,找不到mapper文件(.xml) 错误信息提示: 项目可以正常运行,但是在有请求到达服务器时(有访问数据库的请求),会出现报错!! 错误原因: mybatis没有 ...

  4. Java报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.sirifeng.babytun.dao.GoodsDAO.findById

    前言 最近学vue学得差不多了,想来搭个项目实战一下,结果刚开始搭建SSM框架的时候就来到了我们最喜欢的debug环节 org.apache.ibatis.binding.BindingExcepti ...

  5. IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    有时候解决问题不仅仅是解决问题.-----jstarseven 最近因为开发需要,需要搭建一个ssm开发框架,采用了开发工具IDEA. 整合完了SSM开发框架之后,发布的时候出现org.apache. ...

  6. maven项目 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

    ssm的项目如果在mapper.xml  mapper接口 配置没问题的情况下  项目依然报org.apache.ibatis.binding.BindingException: Invalid bo ...

  7. 【spring boot Mybatis】报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.newhope.interview.dao.UserMapper.add

    报错如下: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.newhope.i ...

  8. 解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.xyfer.dao.UserDao.findById

    在使用Spring整合MyBatis的时候遇到控制台报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (no ...

  9. 关于org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.atguigu.crud.dao.DepartmentMapper.insertSelective的错误

    今天我在使用mybatis逆向工程的时候,由于一个疏忽字打错了..结果花了一早上才把错误找全..广大小伙伴们一定要小心啊(能复制粘贴就别手打) 关于org.apache.ibatis.binding. ...

随机推荐

  1. laravel 的lnmp 的配置

    装了lnmp后,一般用 lnmp vhost add 添加网站 一般 只用重写和ssl功能 再发laravel官方的配置 server { listen 80; server_name example ...

  2. 将shell脚本的执行过程和执行结果导入到log文件中

    [root@localhost scripts]# vim ping.sh #!/bin/bash set -x ##分步执行 exec &> /tmp/log.txt ##脚本执行的过 ...

  3. Linux部署Redis及PHP-redis扩展

    Redis是一个key-value存储系统,属于我们常说的NoSQL.它遵守BSD协议.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API.它常用在缓存.队列.P ...

  4. 关于WPA/WPA2 4次握手

    简单描述一下WPA/WPA2的4次握手中的一些关键词: WPA/WPA2使用4次握手的方式来产生所需要的密钥.四次握手通过一系列的交互,从PMK(Pairwise Master Key)生成PTK(P ...

  5. python基础练习题4

    题目:现有一个数据库记录文件(0005.txt)保证了学生课程签到的数据记录('2017-03-13 11:50:09',271,131),('2017-03-14 11:52:19',273,131 ...

  6. Metafile::EmfToWmfBits的使用

    其中涉及到string转换LPCWSTR以及模块绝对路径的调用 #include <iostream> #include <stdio.h> #include <WIND ...

  7. SpringBoot之模板引擎

    一.Thymeleaf 1.1 集成 templates 在 pom.xml 文件中添加依赖 <dependencies> ...... <dependency> <gr ...

  8. python3 + Tensorflow + Faster R-CNN训练自己的数据

    之前实现过faster rcnn, 但是因为各种原因,有需要实现一次,而且发现许多博客都不全面.现在发现了一个比较全面的博客.自己根据这篇博客实现的也比较顺利.在此记录一下(照搬). 原博客:http ...

  9. tf.split( )和tf.unstack( )

    import tensorflow as tf A = [[1, 2, 3], [4, 5, 6]] a0 = tf.split(A, num_or_size_splits=3, axis=1)#不改 ...

  10. 【leetcode】1214.Two Sum BSTs

    题目如下: Given two binary search trees, return True if and only if there is a node in the first tree an ...