mybatis启动错误

今天在复习mybatis的基础的时候出现了错误信息,具体报错如下。

Exception in thread "main" org.apache.ibatis.binding.BindingException: Type interface com.hxb.mapper.AccountMapper is not known to the MapperRegistry.
	at org.apache.ibatis.binding.MapperRegistry.getMapper(MapperRegistry.java:47)
	at org.apache.ibatis.session.Configuration.getMapper(Configuration.java:745)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.getMapper(DefaultSqlSession.java:292)
	at com.hxb.test.test1.main(test1.java:22)

主要内容是说找不到接口,问题可能有两个,

1、没有将mapper文件注册到resource文件中。

<mappers>
   <mapper resource="com/hxb/mapper/AccountMapper.xml"/>
</mappers>

2、还有一种错误是mapper.xml文件中的namespace文件写错。

<mapper namespace="com/hxb/mapper/AccountMapper"> // 错误写法
<mapper namespace="com.hxb.mapper.AccountMapper"> //  正确写法

总结,不用写后缀的情况下用".",需要后缀的时候用/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值