From a702ff5c36b4f35468548e88cef15f4db2867e8d Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Wed, 20 Aug 2014 09:07:41 +0100 Subject: [PATCH] Make ServerProperties bean conditional on being a webapp --- .../ManagementSecurityAutoConfiguration.java | 8 +++++--- .../ManagementServerPropertiesAutoConfiguration.java | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementSecurityAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementSecurityAutoConfiguration.java index 73c9760f9c..974f8253f8 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementSecurityAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementSecurityAutoConfiguration.java @@ -122,7 +122,7 @@ public class ManagementSecurityAutoConfiguration { @Autowired private SecurityProperties security; - @Autowired + @Autowired(required = false) private ServerProperties server; @Override @@ -148,8 +148,10 @@ public class ManagementSecurityAutoConfiguration { if (this.errorController != null) { ignored.add(normalizePath(this.errorController.getErrorPath())); } - String[] paths = this.server.getPathsArray(ignored); - ignoring.antMatchers(paths); + if (this.server != null) { + String[] paths = this.server.getPathsArray(ignored); + ignoring.antMatchers(paths); + } } private String normalizePath(String errorPath) { diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesAutoConfiguration.java index 2663608ba4..4c5b751301 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesAutoConfiguration.java @@ -20,6 +20,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.security.SecurityProperties; import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration; @@ -55,6 +56,7 @@ public class ManagementServerPropertiesAutoConfiguration { // In case server auto configuration hasn't been included @Bean @ConditionalOnMissingBean + @ConditionalOnWebApplication public ServerProperties serverProperties() { return new ServerProperties(); }