创建类而不是实例,使用spring cgLib动态创建类
while (true)
{
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(Test.class);
enhancer.setUseCache(false);
enhancer.setCallback(new MethodInterceptor()
{
@Override
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy)
throws Throwable
{
return methodProxy.invokeSuper(o,objects);
}
});
enhancer.create();
}
转载于:https://www.cnblogs.com/shanwf/p/7792102.html