mybatis 执行接口的方法
看下执行下面这行代码的时候,都发生了什么 User user = userMapper.getById(1L); 在上一篇中,获取mapper其实是以org.apache.ibatis.binding.MapperProxy为InvocationHandler创建代理对象。那么执行接口的方法的时候,也应该是执行MapperProxy的invoke方法 org.apache.ibatis.binding.MapperProxy#invoke public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { if (Object.class.equals(method.getDeclaringClass())) { return method.invoke(this, args); } else if (isDefaultMethod(method)) { return invokeDefaultMethod(proxy, method, args); } } catch (Throwable t) { throw ExceptionUtil.unwrapThrowable(t); } //封装下method成MapperMethod final MapperMethod