@Bean public WebServerFactoryCustomizer<ConfigurableWebServerFactory> customizer() { return container -> { container.addErrorPages(new ErrorPage(HttpStatus.UNAUTHORIZED, "/unauthenticated")); }; } }
protected void customize(T factory, ManagementServerProperties managementServerProperties, ServerProperties serverProperties) { factory.setPort(managementServerProperties.getPort()); Ssl ssl = managementServerProperties.getSsl(); if (ssl != null) { factory.setSsl(ssl); } factory.setServerHeader(serverProperties.getServerHeader()); factory.setAddress(managementServerProperties.getAddress()); factory.addErrorPages(new ErrorPage(serverProperties.getError().getPath())); }
@Override public final void customize(T factory) { ManagementServerProperties managementServerProperties = BeanFactoryUtils .beanOfTypeIncludingAncestors(this.beanFactory, ManagementServerProperties.class); // Customize as per the parent context first (so e.g. the access logs go to // the same place) customizeSameAsParentContext(factory); // Then reset the error pages factory.setErrorPages(Collections.emptySet()); // and add the management-specific bits ServerProperties serverProperties = BeanFactoryUtils .beanOfTypeIncludingAncestors(this.beanFactory, ServerProperties.class); customize(factory, managementServerProperties, serverProperties); }