记录一次使用Mybatis注解错误引发的异常

记录一次使用Mybatis注解错误引发的异常

2023-09-10 00:03:13.994 ERROR 15160 — [nio-8080-exec-3] 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): com.example.service.SomeService.queryUserByList] with root cause

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.service.SomeService.queryUserByList

错误异常显示Mybatis与Service类之间的某种关系绑定异常,一开始我是顺着Service去找,结果没发现还没进去SomeServiceImpl就开始报错,以为是SomeService层问题,后来证实思路是错的

	@Autowired
    private SomeDao someDao;	//原来是走到这一行就已经报错的,愿意原因是mybatis框架找不到这个bean

    @Override
    public List<User> queryUserByList() {
        return someDao.selectAll();
    }

而出错的地方就是:没有指定包地址

//@MapperScan("com.example.dao")	//正确写法
@MapperScan()				//错误写法
@SpringBootApplication
public class Application {
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
}

虽然后续这问题看着简单多了,跟错误提示也能对上关系,这也算不标准写法的一个小坑吧

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值