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 68ef12952c..4de6268310 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 @@ -415,7 +415,6 @@ public class SpringApplication { } private void refreshContext(ConfigurableApplicationContext context) { - refresh((ApplicationContext) context); if (this.registerShutdownHook) { try { context.registerShutdownHook(); @@ -424,6 +423,7 @@ public class SpringApplication { // Not allowed in some environments. } } + refresh((ApplicationContext) context); } private void configureHeadlessProperty() {