Commit a702ff5c authored by Dave Syer's avatar Dave Syer

Make ServerProperties bean conditional on being a webapp

parent f8477bd6
...@@ -122,7 +122,7 @@ public class ManagementSecurityAutoConfiguration { ...@@ -122,7 +122,7 @@ public class ManagementSecurityAutoConfiguration {
@Autowired @Autowired
private SecurityProperties security; private SecurityProperties security;
@Autowired @Autowired(required = false)
private ServerProperties server; private ServerProperties server;
@Override @Override
...@@ -148,8 +148,10 @@ public class ManagementSecurityAutoConfiguration { ...@@ -148,8 +148,10 @@ public class ManagementSecurityAutoConfiguration {
if (this.errorController != null) { if (this.errorController != null) {
ignored.add(normalizePath(this.errorController.getErrorPath())); ignored.add(normalizePath(this.errorController.getErrorPath()));
} }
String[] paths = this.server.getPathsArray(ignored); if (this.server != null) {
ignoring.antMatchers(paths); String[] paths = this.server.getPathsArray(ignored);
ignoring.antMatchers(paths);
}
} }
private String normalizePath(String errorPath) { private String normalizePath(String errorPath) {
......
...@@ -20,6 +20,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter; ...@@ -20,6 +20,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 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.security.SecurityProperties;
import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration; import org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration;
...@@ -55,6 +56,7 @@ public class ManagementServerPropertiesAutoConfiguration { ...@@ -55,6 +56,7 @@ public class ManagementServerPropertiesAutoConfiguration {
// In case server auto configuration hasn't been included // In case server auto configuration hasn't been included
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
@ConditionalOnWebApplication
public ServerProperties serverProperties() { public ServerProperties serverProperties() {
return new ServerProperties(); return new ServerProperties();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment