|
|
@ -17,8 +17,10 @@ import org.clever.core.AppBasicsConfig; |
|
|
import org.clever.core.AppContextHolder; |
|
|
import org.clever.core.AppContextHolder; |
|
|
import org.clever.core.Assert; |
|
|
import org.clever.core.Assert; |
|
|
import org.clever.core.ResourcePathUtils; |
|
|
import org.clever.core.ResourcePathUtils; |
|
|
|
|
|
import org.clever.core.exception.ExceptionUtils; |
|
|
import org.clever.core.json.jackson.JacksonConfig; |
|
|
import org.clever.core.json.jackson.JacksonConfig; |
|
|
import org.clever.core.mapper.JacksonMapper; |
|
|
import org.clever.core.mapper.JacksonMapper; |
|
|
|
|
|
import org.clever.core.model.response.ErrorResponse; |
|
|
import org.clever.core.reflection.ReflectionsUtils; |
|
|
import org.clever.core.reflection.ReflectionsUtils; |
|
|
import org.clever.core.task.StartupTaskBootstrap; |
|
|
import org.clever.core.task.StartupTaskBootstrap; |
|
|
import org.clever.data.jdbc.JdbcBootstrap; |
|
|
import org.clever.data.jdbc.JdbcBootstrap; |
|
|
@ -33,6 +35,7 @@ import org.clever.web.config.HttpConfig; |
|
|
import org.clever.web.config.WebConfig; |
|
|
import org.clever.web.config.WebConfig; |
|
|
import org.clever.web.filter.*; |
|
|
import org.clever.web.filter.*; |
|
|
import org.clever.web.utils.ApplyWebConfig; |
|
|
import org.clever.web.utils.ApplyWebConfig; |
|
|
|
|
|
import org.clever.web.utils.GlobalExceptionHandler; |
|
|
import org.springframework.boot.autoconfigure.AutoConfigureOrder; |
|
|
import org.springframework.boot.autoconfigure.AutoConfigureOrder; |
|
|
import org.springframework.boot.context.properties.bind.Binder; |
|
|
import org.springframework.boot.context.properties.bind.Binder; |
|
|
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
|
|
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
|
|
@ -122,10 +125,10 @@ public class AppAutoConfiguration { |
|
|
public MultipartConfigElement multipartConfigElement(AppBasicsConfig appBasicsConfig, WebConfig webConfig) { |
|
|
public MultipartConfigElement multipartConfigElement(AppBasicsConfig appBasicsConfig, WebConfig webConfig) { |
|
|
HttpConfig.Multipart multipart = webConfig.getHttp().getMultipart(); |
|
|
HttpConfig.Multipart multipart = webConfig.getHttp().getMultipart(); |
|
|
return new MultipartConfigElement( |
|
|
return new MultipartConfigElement( |
|
|
ResourcePathUtils.getAbsolutePath(appBasicsConfig.getRootPath(), multipart.getLocation()), |
|
|
ResourcePathUtils.getAbsolutePath(appBasicsConfig.getRootPath(), multipart.getLocation()), |
|
|
multipart.getMaxFileSize().toBytes(), |
|
|
multipart.getMaxFileSize().toBytes(), |
|
|
multipart.getMaxTotalRequestSize().toBytes(), |
|
|
multipart.getMaxTotalRequestSize().toBytes(), |
|
|
(int) multipart.getMaxInMemoryFileSize().toBytes() |
|
|
(int) multipart.getMaxInMemoryFileSize().toBytes() |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -193,6 +196,11 @@ public class AppAutoConfiguration { |
|
|
|
|
|
|
|
|
@Bean |
|
|
@Bean |
|
|
public FilterRegistrationBean<HttpFilter> exceptionHandlerFilter() { |
|
|
public FilterRegistrationBean<HttpFilter> exceptionHandlerFilter() { |
|
|
|
|
|
GlobalExceptionHandler.setDefaultHandler((exception, request, response) -> { |
|
|
|
|
|
ErrorResponse res = GlobalExceptionHandler.newErrorResponse(request, exception); |
|
|
|
|
|
res.setError(ExceptionUtils.getStackTraceAsString(exception)); |
|
|
|
|
|
return res; |
|
|
|
|
|
}); |
|
|
FilterRegistrationBean<HttpFilter> filterBean = new FilterRegistrationBean<>(); |
|
|
FilterRegistrationBean<HttpFilter> filterBean = new FilterRegistrationBean<>(); |
|
|
filterBean.setOrder(Ordered.HIGHEST_PRECEDENCE + 300); |
|
|
filterBean.setOrder(Ordered.HIGHEST_PRECEDENCE + 300); |
|
|
filterBean.addUrlPatterns(PathConstants.ALL); |
|
|
filterBean.addUrlPatterns(PathConstants.ALL); |
|
|
|