|
@@ -23,6 +23,7 @@ import net.yyc.common.core.util.SpringContextHolder;
|
|
|
import net.yyc.quartz.constants.QuartzEnum;
|
|
import net.yyc.quartz.constants.QuartzEnum;
|
|
|
import net.yyc.quartz.entity.SysJob;
|
|
import net.yyc.quartz.entity.SysJob;
|
|
|
import net.yyc.quartz.exception.TaskException;
|
|
import net.yyc.quartz.exception.TaskException;
|
|
|
|
|
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.ReflectionUtils;
|
|
import org.springframework.util.ReflectionUtils;
|
|
|
|
|
|
|
@@ -44,8 +45,8 @@ public class SpringBeanTaskInvoke implements ITaskInvoke {
|
|
|
Method method;
|
|
Method method;
|
|
|
Object returnValue;
|
|
Object returnValue;
|
|
|
// 通过Spring上下文去找 也有可能找不到
|
|
// 通过Spring上下文去找 也有可能找不到
|
|
|
- target = SpringContextHolder.getBean(sysJob.getClassName());
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
+ target = SpringContextHolder.getBean(sysJob.getClassName());
|
|
|
if (StrUtil.isNotEmpty(sysJob.getMethodParamsValue())) {
|
|
if (StrUtil.isNotEmpty(sysJob.getMethodParamsValue())) {
|
|
|
method = target.getClass().getDeclaredMethod(sysJob.getMethodName(), String.class);
|
|
method = target.getClass().getDeclaredMethod(sysJob.getMethodName(), String.class);
|
|
|
ReflectionUtils.makeAccessible(method);
|
|
ReflectionUtils.makeAccessible(method);
|
|
@@ -65,6 +66,9 @@ public class SpringBeanTaskInvoke implements ITaskInvoke {
|
|
|
log.error("[QUARTZ] SpringBean任务执行失败 | bean={} method={}", sysJob.getClassName(), sysJob.getMethodName());
|
|
log.error("[QUARTZ] SpringBean任务执行失败 | bean={} method={}", sysJob.getClassName(), sysJob.getMethodName());
|
|
|
throw new TaskException("定时任务springBeanTaskInvoke业务执行失败,任务:" + sysJob.getClassName());
|
|
throw new TaskException("定时任务springBeanTaskInvoke业务执行失败,任务:" + sysJob.getClassName());
|
|
|
}
|
|
}
|
|
|
|
|
+ } catch (NoSuchBeanDefinitionException e) {
|
|
|
|
|
+ log.error("[QUARTZ] Bean未找到 | bean={} 请检查类名", sysJob.getClassName(), e);
|
|
|
|
|
+ throw new TaskException("Bean未找到, bean=" + sysJob.getClassName());
|
|
|
} catch (NoSuchMethodException e) {
|
|
} catch (NoSuchMethodException e) {
|
|
|
log.error("[QUARTZ] Bean方法未找到 | bean={} method={} 请检查方法名和参数是否匹配", sysJob.getClassName(), sysJob.getMethodName(), e);
|
|
log.error("[QUARTZ] Bean方法未找到 | bean={} method={} 请检查方法名和参数是否匹配", sysJob.getClassName(), sysJob.getMethodName(), e);
|
|
|
throw new TaskException("Bean方法未找到, bean=" + sysJob.getClassName() + ", method=" + sysJob.getMethodName());
|
|
throw new TaskException("Bean方法未找到, bean=" + sysJob.getClassName() + ", method=" + sysJob.getMethodName());
|