Method mh = ReflectionUtils.findMethod(SpringContextHolder.getBean(param.get("serviceName")).getClass(), "functionName",new Class[]{ParamClass.class} );
Object obj = ReflectionUtils.invokeMethod(mh, SpringContextHolder.getBean(param.get("serviceName")),param);
参数解释:
serviceName:需要反射调用的service
functionsName:service中具体方法名
ParamClass:方法入参类
param:方法入参
ex:
Method mh = ReflectionUtils.findMethod(SpringContextHolder.getBean(param.get("serviceName")).getClass(), "findAllList4Page",new Class[]{PagePojo.class} );
Object obj = ReflectionUtils.invokeMethod(mh, SpringContextHolder.getBean(param.get("serviceName")),page);
spring通过反射调用service
最新推荐文章于 2023-12-07 11:55:27 发布