//获取到bean serviceBean的类 com.a.DemoService
DemoService serviceBean = (DemoService) SpringContextsUtil.getBean("demoService");
// serviceBean.getClass()就变成代理类型了 class com.sun.proxy.$Proxy27
//所以在代理类型里面找selectSysUserByUserId方法就报错NoSuchMethod
Method mh = ReflectionUtils.findMethod(serviceBean.getClass(), "selectSysUserByUserId",new Class[]{Object.class} );
Object ret = ReflectionUtils.invokeMethod(mh,serviceBean,obj);
要怎么解决,获取spring管理的bean后,取得class还是原来的class
定义了一个service com.a.DemoService
通过工具获取该bean,但是该bean.getClass()与com.a.DemoService不一致,而是个代理,所以没法用发射,怎么解决
慕后森
临摹微笑
相关分类