记录一下写SSM项目遇到的问题

①分页需要的是整型数据,不能是String
②mapper.xml里面namespace名称空间内的指向的接口错误
情况一:org.apache.ibatis.binding.BindingException: Type interface com.anki.dao.BookMapper is not known to the MapperRegistry.
实际上不是未注册mapper,而是指向的实体接口有错误,应该指向 的是com.anki.dao.BookMapper
在这里插入图片描述
在这里插入图片描述
当修改后查询成功,此时是找到了对应的mapper.xml文件,但这个mapper.xml文件和要指向的接口对应不上,所以会显示未注册
情况二:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘bookMapperImpl’: Unsatisfied dependency expressed through field ‘sqlSession’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSession’ defined in class path resource [Spring-dao.xml]: Cannot resolve reference to bean ‘sqlSessionFactory’ while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [Spring-dao.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [Mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is ‘com/anki/dao/BookMapper.xml’. Cause: org.apache.ibatis.builder.BuilderException: Wrong namespace. Expected ‘com.anki.dao.BookMapper’ but found ‘com.anki.dao.BooksDAO’.

上面这一长串仍然是因为namespace名称空间指向的接口写错
在这里插入图片描述
此处仍然应该是com.anki.dao.BookMapper
在这里插入图片描述
因为是先找到com.anki.dao.BookMapper接口,然后再在同一个包下找到同名的mapper.xml文件,但是这个mapper.xml同名的文件中namespace指向的接口又不是自己的接口,所以会显示namespace错误

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值