在配置MyBatis接口映射的Mapper.xml时,提示Invalid bound statement (not found)异常,就算是接口和xml名字相同,路径相同也无法找到,在网上找到了几种解方案。

  • idea默认不扫描src/main/java 下的xml文件,想要放在同一目录下,需要在pom.xml中配置扫描java目录下的xml即可,在build节点下添加:

      <resources>
    <resource>
    <directory>src/main/java</directory>
    <includes>
    <include>**/*.xml</include>
    </includes>
    </resource>
    <resource>
    <directory>src/main/resources</directory>
    </resource>
    </resources>
  • 在resources目录下创建相同的包,运行不可以,需要在spring-mybatis.xml中配置mybatis扫描的地方(这一步不用也行。。):

      <mybatis:scan base-package="com.yl.note.mapper"></mybatis:scan>

    另外,在sqlSessionFactory的Bean中添加:

      <property name="mapperLocations" value="classpath*:com.yl.note.mapper/**/*.xml"/>

可用。

  • 在mybatis的配置文件中添加:

      <mappers>
    
          <!--扫描xml-->
    <mapper resource="com/yl/note/mapper/UserMapper.xml"/>
    <!--扫描接口-->
    <package name="com.yl.note.mapper"/> </mappers>

上述三种任选其一即可,其中第三种有待验证。


2017-11-13

在项目编译的时候发现无法引入properties文件,在resource中引入<include>**/*.properties</include>就行了。。。真是日了狗

		<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>//加入此条目
</includes>
</resource>
</resources>
</build>

idea报错:Invalid bound statement (not found)的更多相关文章

  1. 解决Mybatis 报错Invalid bound statement (not found)

    解决Mybatis 报错Invalid bound statement (not found) 出现此错误的原因 1.xml文件不存在 2.xml文件和mapper没有映射上 namespace指定映 ...

  2. MybatisPlus报错Invalid bound statement (not found)的解决方案

    今天使用MybatisPlus,测试时报错Invalid bound statement (not found) 使用自定义的mapper接口中的方法可以执行,而调用MybatisPlus中baseM ...

  3. springboot+mybatis报错Invalid bound statement (not found)

    今天做项目时报了一个错提示说Invalid bound statement (not found),也就是说mapper接口绑定.xml文件出错了,找不到指定的sql:原因是程序没有把.xml文件编译 ...

  4. IDEA maven项目下测试mybatis例子,使用mappper class或package引入mapper映射文件,总是报错Invalid bound statement(所有配置完全正确)

    困扰几个小时,终于查到解决办法及原因(可以直接到最后看解决方案) 环境就是用IDEA搭建的maven项目,主要jar包引入配置如下 <dependencies> <dependenc ...

  5. Mybatis plus 报错Invalid bound statement (not found) 终极解决办法

    我产生的错误原因是写的mapper继承BaseMapper没有添加泛型: 点进去: 为了解决这个bug,网上很多人也提出了解决办法:1.检查xml文件的namespace是否正确 2.Mapper.j ...

  6. 使用Mybatis时报错Invalid bound statement (not found):

    使用逆向工程时生成的.xml文件在conf目录下,而使用查询方法时,无法在dao包下找到xml文件,所以报错. 测试代码如下所示: @Test public void testSimple() thr ...

  7. 关于Maven整合SSM项目中报错Invalid bound statement (not found):的问题解决

    如图:控制不报错 页面就是报500的错误 查阅了好多资料  都说是Mapper文件写的不对  我仔细找了好几遍也解决不了问题.. 解决: 坑爹的问题害我找了一上午原因,原来是需要在pom.xml文件中 ...

  8. Invalid bound statement (not found): com.xxxx.dao.other.LoginDao.getUser"

    原来是能正常运行的,后想把登录相关的调整一下目录,对应登录的文件都调整到了other下边,启动服务,请求时报错: Invalid bound statement (not found): com.xx ...

  9. MyBatis笔记----报错:Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)解决方法

    报错 Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound st ...

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

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

随机推荐

  1. luogu P1250 种树

    我来总结一下最常用的两种办法 1.贪心 2.差分约束 那么我们先来讲,贪心版<种树> 大家可能知道有一个题和这个类似,那个是钉钉子而这个是种树 我们可以借用钉钉子的思路来想,首先这个是让你 ...

  2. 第六十四天 JS基础操作

    一.分支结构 1.if语句 if基础语句 if(条件表达式){ 代码块: } // 当条件表达式结果为true,会执行代码块:反之不执行 // 条件表达式可以为普通表达式 // 0.undefined ...

  3. RazorEngine

    目标 使用razorengine编译cshtml页面生静态html 制作一个vs2017的插件,实现右击cshtml文件时,编译该文件. 环境 razorengine4.5 / netframewor ...

  4. Java【第一篇】基本语法之--关键字、标识符、变量

    关键字 定义:被Java语言赋予了特殊含义,用做专门用途的字符串(单词)特点:关键字中所有字母都为小写 标识符 Java 对各种变量.方法和类等要素命名时使用的字符序列称为标识符凡是自己可以起名字的地 ...

  5. CAN报文 Intel 格式与Motorola 格式的区别

    当一个信号的数据长度不超过 1 个字节(8 位)时,Intel 与 Motorola 两种格式的 编码结果没有什么不同,完全一样.当信号的数据长度超过 1 个字节(8 位)时,两者的编码结果出现 了明 ...

  6. Linux基本命令总结(九)

    接上篇: 46,scp是secure copy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的.可能会稍微影响一下 ...

  7. Ubuntu16.04 安装g++6

    https://blog.csdn.net/qq_34877350/article/details/81182022 1.安装gcc-6: sudo apt-get update && ...

  8. POJ - 3616 Milking Time (动态规划)

    Bessie is such a hard-working cow. In fact, she is so focused on maximizing her productivity that sh ...

  9. linux c编程之fcntl

    fcntl可实现对指定文件描述符的各种操作,其函数原型如下: int fcntl(int fd, int cmd, ... /* arg */ ); 其中,操作类型由cmd决定.cmd可取如下值: F ...

  10. Linux常用命令大全(非常全!!!)

    Linux常用命令大全(非常全!!!) 最近都在和Linux打交道,感觉还不错.我觉得Linux相比windows比较麻烦的就是很多东西都要用命令来控制,当然,这也是很多人喜欢linux的原因,比较短 ...