From 9e3a2bbdeb4ecf65393faecfe8e4cd0bd54ede8f Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 30 Sep 2020 19:38:06 +0100 Subject: [PATCH] Implement BeanFactoryAware to inject BeanFactory Closes gh-23543 --- .../jdbc/DataSourceInitializerPostProcessor.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerPostProcessor.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerPostProcessor.java index d0e27542e5..62f9737779 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerPostProcessor.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializerPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import javax.sql.DataSource; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.core.Ordered; @@ -30,14 +30,13 @@ import org.springframework.core.Ordered; * * @author Dave Syer */ -class DataSourceInitializerPostProcessor implements BeanPostProcessor, Ordered { +class DataSourceInitializerPostProcessor implements BeanPostProcessor, Ordered, BeanFactoryAware { @Override public int getOrder() { return Ordered.HIGHEST_PRECEDENCE + 1; } - @Autowired private BeanFactory beanFactory; @Override @@ -54,4 +53,9 @@ class DataSourceInitializerPostProcessor implements BeanPostProcessor, Ordered { return bean; } + @Override + public void setBeanFactory(BeanFactory beanFactory) throws BeansException { + this.beanFactory = beanFactory; + } + }