MyWebMvcConfigurer.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.example.config.web;
  2. import lombok.RequiredArgsConstructor;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
  5. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  6. @Configuration
  7. @RequiredArgsConstructor
  8. public class MyWebMvcConfigurer implements WebMvcConfigurer {
  9. private final RequestLogHandlerInterceptor requestLogHandlerInterceptor;
  10. @Override
  11. public void addInterceptors(InterceptorRegistry registry) {
  12. // 添加请求日志拦截
  13. registry.addInterceptor(requestLogHandlerInterceptor)
  14. .addPathPatterns("/**")
  15. .excludePathPatterns("/webjars/**", "/v3/**", "/doc.html", "/favicon.ico", "/test/**");
  16. }
  17. // /**
  18. // * 配置消息转换器
  19. // *
  20. // * @param converters 转换器
  21. // */
  22. // @Override
  23. // public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
  24. // converters.add(mappingJackson2HttpMessageConverter());
  25. // }
  26. //
  27. // /**
  28. // * 配置映射jackson2 http消息转换器
  29. // *
  30. // * @return {@link MappingJackson2HttpMessageConverter}
  31. // */
  32. // @Bean
  33. // public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
  34. // MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
  35. // ObjectMapper mapper = new ObjectMapper();
  36. // mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
  37. // mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
  38. // converter.setObjectMapper(mapper);
  39. // return converter;
  40. // }
  41. }