diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 552e9df024..15a92972de 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -282,12 +282,12 @@ public class SpringApplication { // Create and configure the environment ConfigurableEnvironment environment = getOrCreateEnvironment(); configureEnvironment(environment, args); - if (this.showBanner) { - printBanner(environment); - } for (SpringApplicationRunListener runListener : runListeners) { runListener.environmentPrepared(environment); } + if (this.showBanner) { + printBanner(environment); + } // Create, load, refresh and run the ApplicationContext context = createApplicationContext(); diff --git a/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index ff12539a0f..89e8eb57fe 100644 --- a/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -156,6 +156,14 @@ public class SpringApplicationTests { verify(application, never()).printBanner((Environment) anyObject()); } + @Test + public void disableBannerViaProperty() throws Exception { + SpringApplication application = spy(new SpringApplication(ExampleConfig.class)); + application.setWebEnvironment(false); + application.run("--spring.main.show_banner=false"); + verify(application, never()).printBanner((Environment) anyObject()); + } + @Test @SuppressWarnings("deprecation") public void customBanner() throws Exception {