@Autowired
    private ApplicationContext applicationContext;
        String className = map.get("className").toString();
        Object bean = applicationContext.getBean(className);
        Class<?> aClass = bean.getClass();
        String methodName = map.get("methodName").toString();
        List<String> list = (List) map.get("argsTypes");
        List<Class> arrayList = new ArrayList<>();
        Optional.ofNullable(list).orElse(new ArrayList()).forEach(l->{
            try{
                Class<?> forName = Class.forName(l.toString());
                arrayList.add(forName);
            }catch (Exception e){}
        });
        Class [] argsTypes = arrayList.toArray(new Class[]{});
        List args = (List) map.get("args");
        Method method = aClass.getMethod(methodName, argsTypes);
        Object[] objects = args.toArray(new Object[]{});
        Object invoke = method.invoke(bean,objects );
        return (R)invoke;

调用参数案例

 

{
"className":"QRCodeServiceImpl",
"methodName":"getCabinetList",
"argsTypes":["java.lang.String"],
"args":["2608"]
}

 

相关文章:

  • 2022-12-23
  • 2021-05-22
  • 2021-08-05
  • 2022-12-23
  • 2021-04-05
  • 2021-05-22
  • 2021-12-26
  • 2021-08-21
猜你喜欢
  • 2021-12-19
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
  • 2018-04-26
  • 2021-09-03
  • 2021-12-19
相关资源
相似解决方案