动态代理
public static void main(String[] args) { final ServiceImpl impl =new ServiceImpl(); UserServce servce = (UserServce)Proxy.newProxyInstance(ProjexTest.class.getClassLoader(), new Class[]{UserServce.class}, new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { System.out.println("代理执行前"); try { return method.invoke(impl, args); } finally { System.out.println("代理执行后"); } } }); servce.get();
}
https://blog.csdn.net/weixin_39715061/article/details/80394751