Spring _____2 error learning. Null pointer exception java.lang.NullPointerException

mybatis spring during the integration arise, to identify the reasons is because there is no writing implement interface methods in UserMapperImpl in.

(Use UserMapperImpl of sqlSession property)

To achieve the following:

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();
        
    }
}

 

Guess you like

Origin www.cnblogs.com/xbfchder/p/11267221.html