diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 5ca1aa695e..b440012fc5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -394,7 +394,7 @@ public class SpringApplication { } private void refreshContext(ConfigurableApplicationContext context) { - refresh(context); + refresh((ApplicationContext) context); if (this.registerShutdownHook) { try { context.registerShutdownHook(); @@ -741,10 +741,21 @@ public class SpringApplication { /** * Refresh the underlying {@link ApplicationContext}. * @param applicationContext the application context to refresh + * @deprecated since 2.3.0 in favor of + * {@link #refresh(ConfigurableApplicationContext)} */ + @Deprecated protected void refresh(ApplicationContext applicationContext) { - Assert.isInstanceOf(AbstractApplicationContext.class, applicationContext); - ((AbstractApplicationContext) applicationContext).refresh(); + Assert.isInstanceOf(ConfigurableApplicationContext.class, applicationContext); + refresh((ConfigurableApplicationContext) applicationContext); + } + + /** + * Refresh the underlying {@link ApplicationContext}. + * @param applicationContext the application context to refresh + */ + protected void refresh(ConfigurableApplicationContext applicationContext) { + applicationContext.refresh(); } /**