Be defensive about adding autoconfig report bean

pull/123/merge
Dave Syer 11 years ago
parent 2e926601f2
commit 60f3dd9386

@ -20,6 +20,7 @@ import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationErrorHandler; import org.springframework.boot.SpringApplicationErrorHandler;
import org.springframework.boot.autoconfigure.AutoConfigurationReport.ConditionAndOutcome; import org.springframework.boot.autoconfigure.AutoConfigurationReport.ConditionAndOutcome;
@ -57,8 +58,10 @@ public class AutoConfigurationReportLoggingInitializer implements
@Override @Override
public void initialize(ConfigurableApplicationContext applicationContext) { public void initialize(ConfigurableApplicationContext applicationContext) {
this.loggerBean = new AutoConfigurationReportLogger(applicationContext); this.loggerBean = new AutoConfigurationReportLogger(applicationContext);
applicationContext.getBeanFactory().registerSingleton(LOGGER_BEAN, ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
this.loggerBean); if (!beanFactory.containsBean(LOGGER_BEAN)) {
beanFactory.registerSingleton(LOGGER_BEAN, this.loggerBean);
}
} }
@Override @Override

Loading…
Cancel
Save