|
|
@@ -18,8 +18,9 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
|
|
|
import org.springframework.lang.NonNull;
|
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
|
+import org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration;
|
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
|
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
@@ -33,12 +34,18 @@ import java.util.List;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Configuration
|
|
|
-public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
+public class WebMvcConfig extends DelegatingWebMvcConfiguration {
|
|
|
|
|
|
@Autowired
|
|
|
private OauthInterceptor oauthInterceptor;
|
|
|
|
|
|
@Override
|
|
|
+ protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
+ registry.addResourceHandler("/**").addResourceLocations("classpath:/public/");
|
|
|
+ super.addResourceHandlers(registry);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
|
|
converters.removeIf(converter -> converter instanceof MappingJackson2HttpMessageConverter);
|
|
|
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
|
|
|
@@ -61,6 +68,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(objectMapper);
|
|
|
converters.add(converter);
|
|
|
log.info("{}", converters.size());
|
|
|
+ super.configureMessageConverters(converters);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -77,8 +85,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
public void afterCompletion(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler, Exception ex) {
|
|
|
ServletContext.clean();
|
|
|
}
|
|
|
- }).addPathPatterns("/**");
|
|
|
- registry.addInterceptor(this.oauthInterceptor).addPathPatterns("/**");
|
|
|
+ }).addPathPatterns("/**").excludePathPatterns("/static/**", "/index.html");
|
|
|
+ registry.addInterceptor(this.oauthInterceptor).addPathPatterns("/**").excludePathPatterns("/static/**", "/index.html");
|
|
|
+ super.addInterceptors(registry);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -88,6 +97,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|
|
.allowCredentials(true)
|
|
|
.allowedMethods("GET", "POST", "DELETE", "PUT", "PATCH")
|
|
|
.maxAge(3600);
|
|
|
+ super.addCorsMappings(registry);
|
|
|
}
|
|
|
}
|
|
|
|