try {
clazz = Class.forName(cron.getClassName());
String className = lowerFirstCapse(clazz.getSimpleName());
Object bean = (Object) ApplicationContextHelper.getBean(className);
Method method = ReflectionUtils.findMethod(bean.getClass(), cron.getMethod(), String[].class);
String[] orgIds = cron.getOrgIds().split(",");
ReflectionUtils.invokeMethod(method, bean, (Object)orgIds);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
加个Object强转,我都服了 这波傻波操作,还尼玛要强转!!!
建议:
import org.apache.commons.lang3.reflect.MethodUtils;
Method method = MethodUtils.getAccessibleMethod(bean.getClass(), cron.getMethod(), String[].class);
MethodUtils.invokeExactMethod(bean, method.getName(),orgIds);