add banner

add banner
This commit is contained in:
shimingxy
2020-01-06 21:36:51 +08:00
parent b6b81c30e7
commit 8110d99451
22 changed files with 102 additions and 349 deletions

View File

@@ -2,11 +2,15 @@ package org.maxkey;
import org.maxkey.authz.oauth2.provider.endpoint.TokenEndpointAuthenticationFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpStatus;
@Configuration
@ImportResource(locations={"classpath:spring/maxkey.xml"})
@@ -32,4 +36,24 @@ public class MaxKeyConfig {
registration.setOrder(1);
return registration;
}
/**
* 配置默认错误页面仅用于内嵌tomcat启动时
* 使用这种方式在打包为war后不起作用
*
* @return
*/
@Bean
public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() {
return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
@Override
public void customize(ConfigurableWebServerFactory factory) {
ErrorPage errorPage400 = new ErrorPage(HttpStatus.BAD_REQUEST,"/error-400");
ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND,"/error-404");
ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/error-500");
factory.addErrorPages(errorPage400, errorPage404,errorPage500);
}
};
}
}