在进行 mybatis spring 整合中出现的,查明原因是因为在 UserMapperImpl中没有写接口方法的实现。
(使用UserMapperImpl的sqlSession属性)
实现如下:
public class UserMapperImpl implements UserMapper { //添加sqlSession属性 private SqlSession sqlSession; public void setSqlSession(SqlSession sqlSession) { this.sqlSession = sqlSession; } public List<User> getUser() { UserMapper mapper = sqlSession.getMapper(UserMapper.class); return mapper.getUser(); } }