maven项目使用mybatis时,找不到mapper文件(.xml)

错误信息提示:

项目可以正常运行,但是在有请求到达服务器时(有访问数据库的请求),会出现报错!!
错误原因:
  • mybatis没有找到对应的请求调用持久层的方法

查错方法:

首先检查target-->classes文件夹被dao层文件夹内是否有对应mapper.xml文件,如果有xml文件,则一般是配置文件出现的错误,如果没有xml类型的文件,则是没有拷贝资源文件的原因。下面是对应的解决方法。

1.名称不一致问题

排查步骤:
  • 检查mapper接口与mapper.xml文件名称是否一致

  • mapper.xml里面指定的namespace是否是mapper接口,名称是否正确

  • mapper接口内的方法名时候与mapper.xml文件中的id对应

  • 检查mybatis配置文件(SqlMapConfig.xml)与spring配置文件指定的名称是否一致

  • web.xml配置文件中指定的spring配置文件名称是否与真实的spring配置文件的名称路径一致

2. 默认拷贝资源文件无效的问题(target目录下的classes文件夹内没有对应的mapper.xml)---默认不拷贝src/main/java下面的配置文件

解决方案【以下三种方案选一种即可】(ecplise):
  • 项目名--右击--build path--config build path--source--src/main/java--out.....---edit---add---**/*.xml

推荐下面方式,ecplise和idea都可使用
  • pom.xml文件中 添加资源文件拷贝插件 添加自定义的资源文件拷贝行为(如果配置src/main/java的拷贝行为,会导致默认的拷贝行为失效,即不再拷贝src/main/resouce文件夹内的位置文件,应该将两个都拷贝行为都配置一下)

    <!-- 资源文件拷贝插件 -->
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.7</version>
    <configuration>
    <encoding>UTF-8</encoding>
    </configuration>
    </plugin>

<!-- 资源文件拷贝插件 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
  • 将mapper接口和mapper.xml文件分开 在resouce文件夹内模仿mapper接口文件层次创建文件夹,将mapper.xml文件放在里面,编译输出时,会输出在target目录下的同一位置

温馨提示:使用IDEA将会避免大部分问题,IDEA真香!!!

Maven项目使用mybatis报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的更多相关文章

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

    idea在使用maven构建的项目中使用mybatis时报错org.apache.ibatis.binding.BindingException: Invalid bound statement (n ...

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

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

  3. 项目启动报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.wuhongyu.mapper.OrdersMapper.selectByExample

    在用maven配置mybatis环境时出现此BindingExceptiony异常,发现在classes文件下没有mapper配置文件,应该是maven项目没有扫描到mapper包下的xml文件, 在 ...

  4. mybatis plus 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 少了个范型

  5. Srping mvc mabatis 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

    我的Mapper采用接口+注解的方式注入 @Repository(value="customerServOutCallMapper")public interface Custom ...

  6. mybatis错误之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    玩了MyBatis差不多有两年了,中间也玩过MyBatis-Plus,这个MyBatis-Plus其实与MyBatis的区别并不大.今天写博客业务代码的时候,犯一个初学者犯过的错误. 错误信息如下:o ...

  7. mybatis使用时org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误

    最近在使用mybatis时,出现了 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): 这 ...

  8. 使用maven整合mybatis时出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    分析原因是mybatis的映射文件的问题,首先进行分析排查: 1.检查mapper接口和对应的xml文件的包名是否对应 2.检查xml文件的namespace与mapper接口的包名是否对应 3.检查 ...

  9. 解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)...

    在IDEA中将xxxMapper.xml文件创建在(src/main/java)目录中,运行报错:org.apache.ibatis.binding.BindingException: Invalid ...

随机推荐

  1. Spring 框架基础(06):Mvc架构模式简介,执行流程详解

    本文源码:GitHub·点这里 || GitEE·点这里 一.SpringMvc框架简介 1.Mvc设计理念 MVC是一种软件设计典范,用一种业务逻辑.数据.界面显示分离的方法组织代码,将业务逻辑聚集 ...

  2. mysql 中文不显示问题

    MySQL的字符集支持(Character Set Support)有两个方面: 字符集(Character set)和排序方式(Collation).对于字符集的支持细化到四个层次: 服务器(ser ...

  3. TableViewCell的封装(显示不同内容)

    http://blog.csdn.net/qq_24513939/article/details/45968123

  4. 从零开始openGL—— 二、 基本图形绘制

    前言 这是从零开始openGL系列文章的第二篇,在上篇文章中介绍了基本的环境配置,这篇文章将介绍如何绘制基本图形(圆.三角形.立方体.圆柱.圆锥). 基本框架 下面这里我先给出opengl的3D绘图的 ...

  5. 纯CSS与HTML实现垂直时间轴

    原创YouTube HTML源码 <!DOCTYPE html> <html lang="en"> <head> <meta charse ...

  6. 利用 FC + OSS 快速搭建 Serverless 实时按需图像处理服务

    作者:泽尘 简介 随着具有不同屏幕尺寸和分辨率设备的爆炸式增长,开发人员经常需要提供各种尺寸的图像,从而确保良好的用户体验.目前比较常见的做法是预先为一份图像存放多份具有不同尺寸的副本,在前端根据用户 ...

  7. flex布局的兼容问题

    一.W3C各个版本的flex 2009 version 标志:display: box; or a property that is box-{*} (eg. box-pack) 2011 versi ...

  8. Atoder-3620

    The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to ...

  9. 四点之间最短路(spfa+优先队列+枚举优化)UESTC1955喜马拉雅山上的猴子

    喜马拉雅山上的猴子 Time Limit: 1000 MS     Memory Limit: 256 MB Submit Status 余周周告诉我喜马拉雅山上有猴子,他们知道点石成金的方法.我不信 ...

  10. 在5分钟内将Spring Boot作为Windows服务启动

    分享优锐课学习笔记~来看一下如何使用Spring Boot创建Windows服务以及通过配置详细信息来快速启动并运行. 最近不得不将Spring Boot应用程序部署为Windows服务,感到惊讶的是 ...