1. 程式人生 > >swagger被攔截器攔截

swagger被攔截器攔截

配置swagger文件,被攔截器攔截不能使用

攔截器中新增以下配置,適當修改即可使用

重寫addInterceptors

registry.addInterceptor(new UserInterceptor()).addPathPatterns("/**")
        .excludePathPatterns("/rest/login.do/info")
        .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");

重寫addResourceHandlers

registry.addResourceHandler("swagger-ui.html")
        .addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
        .addResourceLocations("classpath:/META-INF/resources/webjars/");