123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package com.example.config.web;
- import lombok.RequiredArgsConstructor;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
- import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
- @Configuration
- @RequiredArgsConstructor
- public class MyWebMvcConfigurer implements WebMvcConfigurer {
- private final RequestLogHandlerInterceptor requestLogHandlerInterceptor;
- @Override
- public void addInterceptors(InterceptorRegistry registry) {
- // 添加请求日志拦截
- registry.addInterceptor(requestLogHandlerInterceptor)
- .addPathPatterns("/**")
- .excludePathPatterns("/webjars/**", "/v3/**", "/doc.html", "/favicon.ico", "/test/**");
- }
- // /**
- // * 配置消息转换器
- // *
- // * @param converters 转换器
- // */
- // @Override
- // public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
- // converters.add(mappingJackson2HttpMessageConverter());
- // }
- //
- // /**
- // * 配置映射jackson2 http消息转换器
- // *
- // * @return {@link MappingJackson2HttpMessageConverter}
- // */
- // @Bean
- // public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
- // MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
- // ObjectMapper mapper = new ObjectMapper();
- // mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- // mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
- // converter.setObjectMapper(mapper);
- // return converter;
- // }
- }
|