GetMappingvalue = loadAndInvokeJar 运行一般的jar包默认的路径 public String loadAndInvokeJar throws NoSuchMethodException InvocationTargetException IllegalAccessException InstantiationException Class
@GetMapping(value = "/loadAndInvokeJar") //运行一般的jar包,默认的路径 public String loadAndInvokeJar() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException { Class<?> clasz = DynamicJar.init(jarPath).load(fullClassNameJar); MainExample plugin = (MainExample) clasz.newInstance(); String[] mainArgs = {data}; Object result = MethodUtils.invokeExactMethod(clasz, methodNameJar, (Object) mainArgs); System.out.println("插件返回解析数据:"+result.toString()); return result.toString();
原文地址: https://www.cveoy.top/t/topic/h8Ge 著作权归作者所有。请勿转载和采集!