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 {
@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) {
......
......@@ -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();
}
......
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