import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;import org.springframework.aop.MethodBeforeAdvice;
public class AopProxyFactory {
public static Object createProxy(final Object target,final MethodBeforeAdvice methodBeforeAdive){
return Proxy.new ProxyEnstance(
target.getClass().getClassLoader(),
target.getClass().getInterfaces(),
new InvocationHandler(){
public Object invoke(Object proxy,Method method,Object[] args)throws Throwable{
methodBeforeAdive.before(method, args, target);
return method.invoke(target, args);
}
});
}
}上面这段代码中eclipse提示Proxy这个错误是怎么回事?

解决方案 »

  1.   

    return Proxy.new ProxyEnstance( 
    是I 不是E
      

  2.   

    Proxy.new ProxyEnstance,楼主真是高人阿!!!Proxy.newProxyInstance,请仔细看看这两者区别吧
      

  3.   

    public class AopProxyFactory {
    public static Object createProxy(final Object target, final MethodBeforeAdvice methodBeforeAdive) {
    return Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), new InvocationHandler() {
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    methodBeforeAdive.before(method, args, target);
    return method.invoke(target, args);
    }
    }); }
    }是newProxyInstance不是new ProxyInstance
      

  4.   

    哦,呵呵,知道了,按书上敲的,可能写new 习惯了,半天没检查出来什么问题,精神萎靡,几天没睡好了