修复执行任务时,若方法入口在任务的父类,则无法执行的问题

实际项目开发中,可能会为所有定时任务类建一个共同的父类,任务的执行入口在父类定义,以便管理。此时使用 `getDeclaredMethod()` 是无法从子类找到要执行的方法的,而是要换用 `getMethod()` 方法。

Signed-off-by: 捏造的信仰 <yiding.he@gmail.com>
This commit is contained in:
捏造的信仰 2022-08-23 05:36:29 +00:00 committed by Gitee
parent 99d1760b98
commit a78b5b7b2a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 2 additions and 2 deletions

View File

@ -52,12 +52,12 @@ public class JobInvokeUtil
{ {
if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0)
{ {
Method method = bean.getClass().getDeclaredMethod(methodName, getMethodParamsType(methodParams)); Method method = bean.getClass().getMethod(methodName, getMethodParamsType(methodParams));
method.invoke(bean, getMethodParamsValue(methodParams)); method.invoke(bean, getMethodParamsValue(methodParams));
} }
else else
{ {
Method method = bean.getClass().getDeclaredMethod(methodName); Method method = bean.getClass().getMethod(methodName);
method.invoke(bean); method.invoke(bean);
} }
} }