救命 之前安装jdk,结果没安装明白就直接给删了,现在重新安装结果显示错误1316指定的账户已存在,安装不上要怎么办呀?
安装软件跟账户没关系吧,建议本机查一下环境变量,把环境变量清除干净。
【相关推荐】
public interface UserService {
int insert();
String query();
}
public class UserServiceImpl implements UserService{
@Override
public int insert() {
System.out.println("insert");
return 0;
}
@Override
public String query() {
System.out.println("query");
return null;
}
}
public class UserServiceInvocationHandler implements InvocationHandler {
// 持有目标对象
private Object target;
public UserServiceInvocationHandler(Object target){
this.target = target;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
System.out.println("invocation handler");
// 通过反射调用目标对象的方法
return method.invoke(target,args);
}
}
public class MainApplication {
public static void main(String[] args) {
// 指明一个类加载器,要操作class文件,怎么少得了类加载器呢
ClassLoader classLoader = MainApplication.class.getClassLoader();
// 为代理对象指定要是实现哪些接口,这里我们要为UserServiceImpl这个目标对象创建动态代理,所以需要为代理对象指定实现UserService接口
Class[] classes = new Class[]{UserService.class};
// 初始化一个InvocationHandler,并初始化InvocationHandler中的目标对象
InvocationHandler invocationHandler = new UserServiceInvocationHandler(new UserServiceImpl());
// 创建动态代理
UserService userService = (UserService) Proxy.newProxyInstance(classLoader, classes, invocationHandler);
// 执行代理对象的方法,通过观察控制台的结果,判断我们是否对目标对象(UserServiceImpl)的方法进行了增强
userService.insert();
}
}