Skip to content

Commit

Permalink
Merge pull request xuxueli#2990 from massivedfish/master
Browse files Browse the repository at this point in the history
fix:修复xxlJob initJobHandlerMethodRepository 调用getBean方法 提前初始化Bean 导致懒…
  • Loading branch information
xuxueli authored Oct 2, 2022
2 parents 3cf27f9 + b4835d4 commit d7ee76f
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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;

Expand Down Expand Up @@ -84,7 +85,14 @@ private void initJobHandlerMethodRepository(ApplicationContext applicationContex
// 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<Method, XxlJob> annotatedMethods = null; // referred to :org.springframework.context.event.EventListenerMethodProcessor.processBean
try {
Expand Down

0 comments on commit d7ee76f

Please sign in to comment.