From b4835d40f18084e9facb9ec0d41993fdc885aca8 Mon Sep 17 00:00:00 2001 From: jiabao1 Date: Fri, 23 Sep 2022 18:09:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8DxxlJob=20initJobHandlerMe?= =?UTF-8?q?thodRepository=20=E8=B0=83=E7=94=A8getBean=E6=96=B9=E6=B3=95=20?= =?UTF-8?q?=E6=8F=90=E5=89=8D=E5=88=9D=E5=A7=8B=E5=8C=96Bean=20=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E6=87=92=E5=8A=A0=E8=BD=BD=E6=B3=A8=E8=A7=A3=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../job/core/executor/impl/XxlJobSpringExecutor.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java b/xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java index 3c2a67d5..16dbc97e 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java @@ -11,6 +11,7 @@ import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.SmartInitializingSingleton; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; +import org.springframework.context.annotation.Lazy; import org.springframework.core.MethodIntrospector; import org.springframework.core.annotation.AnnotatedElementUtils; @@ -84,7 +85,14 @@ public class XxlJobSpringExecutor extends XxlJobExecutor implements ApplicationC // init job handler from method String[] beanDefinitionNames = applicationContext.getBeanNamesForType(Object.class, false, true); for (String beanDefinitionName : beanDefinitionNames) { - Object bean = applicationContext.getBean(beanDefinitionName); + Object bean = null; + Lazy onBean = applicationContext.findAnnotationOnBean(beanDefinitionName, Lazy.class); + if (onBean!=null){ + logger.debug("xxl-job skip @Lazy Bean:{}",beanDefinitionName); + continue; + }else { + bean = applicationContext.getBean(beanDefinitionName); + } Map annotatedMethods = null; // referred to :org.springframework.context.event.EventListenerMethodProcessor.processBean try {