SpringBoot中WebMvcConfigurerAdapter已过时

WebMvcConfigurerAdapter is deprecated

Posted by alovn on April 3, 2019

Spring Boot2.0的版本中编译器会提示WebMvcConfigurerAdapter已过时了, 针对这个情况有两种解决方案。

替代方案一

1
2
3
4
5
6
7
8
@Configuration
public class WebMvcConfg implements WebMvcConfigurer {
    //code
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //registry.addInterceptor(getSecurityInterceptor());
    }
}

替代方案二

1
2
3
4
5
6
7
8
@Configuration
public class WebMvcConfg extends WebMvcConfigurationSupport {
    //code
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //registry.addInterceptor(getSecurityInterceptor());
    }
}

推荐使用第二种。