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 a7c50a6ca2..58c19091d3 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -877,7 +877,7 @@ public class SpringApplication { public void setApplicationContextClass( Class applicationContextClass) { this.applicationContextClass = applicationContextClass; - if (isSpringWebAvailable() && !WebApplicationContext.class.isAssignableFrom( + if (!isSpringWebAvailable() || !WebApplicationContext.class.isAssignableFrom( applicationContextClass)) { this.webEnvironment = false; }