springboot WebMvcConfigurerAdapter替代

过时应用:

@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/user/login");
        super.addInterceptors(registry);
    }
}

新的替代:

@Configuration
public class WebMvcConfg implements WebMvcConfigurer {
  //一系列实现方法
}
@Configuration
public class WebMvcConfg extends WebMvcConfigurationSupport {
  @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/user/login");
        super.addInterceptors(registry);
    }
}
推荐使用后面那种方式

 

posted @ 2018-07-06 20:41  花拾夕  阅读(8385)  评论(0编辑  收藏  举报