org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.gong.mybatis.dao.EmployeeMapper.getEmpById

在mybatis全局配置文件中利用mappers中的mapper中的class属性配置sqll映射文件时出现该问题:以EmployeeMapper.java和EmployeeMapper.xml为例

在使用class配置sql映射文件时:

需注意三点:

1、EmployeeMapper.java和EmployeeMapper.xml需在同一个包下,且类名和xml文件名要相同;

2、在Mybatis全局配置文件中注册映射文件时要正确:

    <mappers>
        <mapper class="com.gong.mybatis.dao.EmployeeMapper" />
    </mappers>

3、在EnployeeMapper.xml中:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gong.mybatis.dao.EmployeeMapper">
    <select id="getEmpById" resultType="com.gong.mybatis.bean.Employee">
        select id,last_name lastName,email,gender from tbl_employee where id = #{id}
    </select>
</mapper>

在EmployeeMapper.java中:

package com.gong.mybatis.dao;

import com.gong.mybatis.bean.Employee;

public interface EmployeeMapper {
    public Employee getEmpById(Integer id);
}

namespace的值要与EmployeeMapper接口中的全类名保持一致,同时id的值要与相关的方法名保持一致。

4、如果这些都是正确的,那么可以做如下处理:

  • 去掉EmployeeMapper.xml文件中的中文注释(我就是这么解决的)
  • 在EmployeeMapper.xml文件中加一个空格或者空行然后保存

原文地址:https://www.cnblogs.com/xiximayou/p/12209227.html

时间: 2024-11-01 17:20:40

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.gong.mybatis.dao.EmployeeMapper.getEmpById的相关文章

spring boot 整合mybatis:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

最近在学习SpringBoot,遇到些异常情况: 1.异常信息 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.hippo.demo.dao.Chapter6DemoMapper.insert 2.解决方案 问题找了很久,发现使用@Select.@Insert.@Update.@Delete注解代替xxxMapper.xml里面的内容,不存在异常,那就是扫描xxxMapper

通过maven test 报org.apache.ibatis.binding.BindingException: Invalid bound statement

背景 直接使用eclipse工具去执行,没有问题,通过testng.xml去执行,没有问题,但通过mvn clean test执行,就报错,提示org.apache.ibatis.binding.BindingException: Invalid bound statement 解决方法 首先先肯定的是:mybatis的配置是没有问题,因为eclipse可以正常执行: 在eclipse中把mapper的xml文件放到src代码目录下是可以一起打包进classes的,而maven去编译的时候不会,

Exception:HTTP Status 500 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

主要错误信息如下: HTTP Status 500 - org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) description The server encountered an internal error that prevented it from fulfilling this request. exception java.lang.RuntimeException: org

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

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): da.huying.usermanage.mapper.UserMapper.queryUserById    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:196)    at org.apache.ibatis.bindi

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

报错 Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectarticle at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:230) at or

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

有时候解决问题不仅仅是解决问题.-----jstarseven 最近因为开发需要,需要搭建一个ssm开发框架,采用了开发工具IDEA. 整合完了SSM开发框架之后,发布的时候出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found... 一开始以为是自己配置文件写的有问题找了半天也没有问题,之后才发现是自己对IDEA工具使用的不够熟悉. 先说该异常常见解决方案: 一般是xml映射文件有错误.但

MyBatis笔记----报错Exception in thread &quot;main&quot; org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectUser

信息: Refreshing org[email protected]41cf53f9: startup date [Wed Apr 05 16:48:12 CST 2017]; root of context hierarchy 四月 05, 2017 4:48:12 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definiti

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.baway.dao.UserMapper.register

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.baway.dao.UserMapper.register    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)    at org.apache.ibatis.binding.MapperMethod.<

【mybatis】mybatis访问报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

mybatis访问报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 需要检查的步骤: 1.是否mapper.java文件上使用了注解@Mapper  或者 在启动类上扫描了Mapper类 @MapperScan("com.swapping.springcloud.ms.integral.mapper")   [注意扫描的包名是否正确] 2.注意mapper.xml文件中的