org.apache.ibatis.binding.BindingException: Invalid bound statement

2 篇文章 0 订阅
1 篇文章 0 订阅

org.apache.ibatis.binding.BindingException: Invalid bound statement

1. Problem screenshot:

2018-12-27 22:08:18.976 ERROR 42512 --- [nio-8090-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): catchm.dao.SysUserDao.insert] with root cause

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): xxx.dao.xxxDao.insert
	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:227) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:49) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65) ~[mybatis-3.4.6.jar:3.4.6]
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58) ~[mybatis-3.4.6.jar:3.4.6]
	at com.sun.proxy.$Proxy63.insert(Unknown Source) ~[na:na]
	at catchm.service.impl.SysUserServiceImpl.insert(SysUserServiceImpl.java:24) ~[classes/:na]
	at catchm.inte.api.sys.userApi.create(userApi.java:33) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]

2. Way of resolution:

Current relevant configuration:

  • Application.java
@MapperScan("xxx.dao")
@SpringBootApplication(scanBasePackages = "xxx")
public class XXXApplication{

    public static void main(String[] args){
        SpringApplication.run(XXXApplication.class, args);
    }

}
  • application.yml
mybatis:
  mapper-locations:  classpath*:xxx/mybatis/*Mapper.xml
  • project catalog
+ Module1
	- Application and config

+ Module2
	+ src
		+ main
			+ java
				+ xxx.dao
					- nameDao.java
			+ resources
				+ xxx.mybatis
					- nameMapper.xml

Analysis of the problem found that mapperInterface(dao) had been obtained, but it was unable to connect to mapper, so it was mapper that had a problem in configuration, and resource path was an error:

  • modify application.yml: xxx/mybatis to xxx.mybatis, because the former is the way to write source root path, but mapper belong to resource root. I use idea, and the package name format is very similar!
mybatis:
  mapper-locations:  classpath*:xxx.mybatis/*Mapper.xml

3. Tips:

  1. Resource reference is different from the package reference;
  2. I’m ashamed of my carelessness and write this article.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值