①分页需要的是整型数据,不能是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错误