解决Springboot配置excludePathPatterns不生效的问题

目录
  • Springboot配置excludePathPatterns不生效
    • 先说解决方案
  • 使用excludePathPatterns过滤Swagger路径失败

Springboot配置excludePathPatterns不生效

先说解决方案

1.因为我在@RequestMapping中加了一个路径,所以  匹配原则应该是   /**/user/login/**

2.我的excludePathPatterns配置

3.分析:Interceptor加载关键所在!要在从url第一个"/"开始 **代表所有目录及路径

使用excludePathPatterns过滤Swagger路径失败

实际excludePathPatterns是起作用了,但是由于Swagger并不是只需要开放一个URL,而是有很多,可以通过浏览器f12查看被拦截的路径有哪些,然后全部开放即可。

.excludePathPatterns("/swagger-ui.html")
.excludePathPatterns("/configuration/ui")
.excludePathPatterns("/swagger-resources")
.excludePathPatterns("/configuration/security")
.excludePathPatterns("/v2/api-docs")
.excludePathPatterns("/error")
.excludePathPatterns("/webjars/**")
.excludePathPatterns("/**/favicon.ico")

以上为个人经验,希望能给大家一个参考,也希望大家多多支持我们。

(0)

相关推荐

  • SpringBoot @CompentScan excludeFilters配置无效的解决方案

    目录 @CompentScan excludeFilters配置无效 FilterType @ComponentScan excludeFilters 自定义过滤器 一.@ComponentScan的作用 二.定义组件 三.在主程序类中测试 四.@ComponentScan中excludeFilters使用 @CompentScan excludeFilters配置无效 @CompentScan 注解配置需要扫描的包 excludeFilters 是其中一个配置项,用于排除不需要扫描的类 Fil

  • springboot Interceptor拦截器excludePathPatterns忽略失效

    springboot Interceptor拦截器excludePathPatterns忽略失效 excludePathPatterns方法是排除访问路径,但是当你排除的url路径在项目中并不存在的时候,springboot会将路径编程/error,从而无法进行排除. 例如下面代码: registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**").excludePathPatterns("/login&q

  • 解决SpringBoot自定义拦截器和跨域配置冲突的问题

    目录 SpringBoot自定义拦截器和跨域配置冲突 技术栈 问题引出 原代码 新代码 SpringBoot 拦截器和addCorsMappings冲突 SpringBoot自定义拦截器和跨域配置冲突 技术栈 vue-cli3,springboot 2.3.2.RELEASE 问题引出 在做毕业设计过程中用到了自定义拦截器验证登录.同时在springboot配置类中设置了跨域问题,出现跨域失败的情况. 原代码 @Configuration public class WebConfig exten

  • 解决Springboot配置excludePathPatterns不生效的问题

    目录 Springboot配置excludePathPatterns不生效 先说解决方案 使用excludePathPatterns过滤Swagger路径失败 Springboot配置excludePathPatterns不生效 先说解决方案 1.因为我在@RequestMapping中加了一个路径,所以  匹配原则应该是   /**/user/login/** 2.我的excludePathPatterns配置 3.分析:Interceptor加载关键所在!要在从url第一个"/"开

  • 解决springboot引入swagger2不生效问题

    目录 问题描述: springboot引入swagger2的步骤: ①引入依赖 ②编写Swagger2的配置类 ③在controller中添加注解:按需添加注解 ④在model(pojo)上加注解,按需添加 一些注解的使用 今天遇到跟同事遇到一个由于失误导致的问题,也可以说比较难发现了.在此记录一下(我们用的springboot是2.0.3,swagger是2.2.2) 问题描述: swagger修改title,description等都不生效.并且启动springboot,没有有去加载swag

  • 解决Springboot @WebFilter拦截器未生效问题

    问题描述 @WebFilter(filterName = "ssoFilter",urlPatterns = "/*") 未生效拦截器 解决方法 在springboot启动类上添加 @ServletComponentScan(basePackages = "full.package.path") 路径替换为@WebFilter所在包 补充知识:在spring boot中使用@WebFilter配置filter(包括排除URL) 我就废话不多说了,

  • 关于springboot配置druid数据源不生效问题(踩坑记)

    pom文件 如果你的springboot项目要用到druid,那么这三个依赖必不可少: <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.10</version> </dependency> <!--Druid--> <depen

  • 解决springboot yml配置 logging.level 报错问题

    如下所示: logging: config: classpath:spring-logback.xml pattern: console: "%d - %msg%n" level: info 直接写 level: info 会报错: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'logging.level' to java.util.Map

  • 详解springboot设置默认参数Springboot.setDefaultProperties(map)不生效解决

    我们都知道springboot 由于内置tomcat(中间件)直接用启动类就可以启动了. 而且我们有时想代码给程序设置一些默认参数,所以使用方法Springboot.setDefaultProperties(map) SpringApplication application = new SpringApplication(startClass); // Map<String, Object> params = new HashMap<>(); params.put("l

  • 解决springboot中配置过滤器以及可能出现的问题

    在springboot添加过滤器有两种方式: 1.通过创建FilterRegistrationBean的方式(建议使用此种方式,统一管理,且通过注解的方式若不是本地调试,如果在filter中需要增加cookie可能会存在写不进前端情况) 2.通过注解@WebFilter的方式 通过创建FilterRegistrationBean的方式创建多个filter以及设置执行顺序: 1.创建两个实现Filter接口的类TestFilter1 .TestFilter2 package com.aoxun.c

  • springboot 配置日志 打印不出来sql的解决方法

    今天整合springboot2 + mybatis + logback 遇到了在日志中sql打印不出来的坑,在网上找了好久,都不是我遇到的问题,这里吐槽一下下现在的博客质量,好多都是抄袭的,也没有标注转载. 先说下要将sql打印到日志的配置 1.在mybatis.xml配置中增加以下配置 <!--指定 MyBatis 增加到日志名称的前缀.--> <setting name="logPrefix" value="m-shop-mybatis-sql.&quo

  • 解决springboot利用ConfigurationProperties注解配置数据源无法读取配置信息问题

    @ConfigurationProperties是springboot新加入的注解,主要用于配置文件中的指定键值对映射到一个java实体类上.那么它是怎么发挥作用的呢?下面我们将揭开@ConfigurationProperties的魔法. ConfigurationPropertiesBindingPostProcessor这个bean后置处理器,就是来处理bean属性的绑定的,这个bean后置处理器后文将称之为properties后置处理器.你需要知道以下几件事: ioc容器context的e

随机推荐