首页 > 代码库 > MyBatis笔记----报错Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectUser

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

信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@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 definitions from class path resource [com/ij34/mybatis/applicationContext.xml]Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ij34.model.UserMapper.selectUser at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:230) at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48) at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58) at com.sun.proxy.$Proxy4.selectUser(Unknown Source) at com.ij34.bean.Test.main(Test.java:24)

 

       解决:

  1. 检查xml文件所在的package名称是否和interface对应的package名称一一对应
  2. 检查xml文件的namespace是否和xml文件的package名称一一对应
  3. 检查函数名称能否对应上
  4. 去掉xml文件中的中文注释
  5. 随意在xml文件中加一个空格或者空行然后保存

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