【问题标题】:Invalid mapping pattern detected: /**/swagger-ui/** : Is there any solution to this issue?检测到无效的映射模式:/**/swagger-ui/**:这个问题有什么解决方案吗?
【发布时间】:2022-07-05 14:45:02
【问题描述】:

当我将 Spring Boot API 升级到 2.6.1 版本时,我收到了这个错误。 我的 API 中的 URL ant 匹配器喜欢:/v1/token/**

此错误的任何解决方案:

Invalid mapping pattern detected: /**/swagger-ui/**
^
No more pattern data allowed after {*...} or ** pattern element

Action:

Fix this pattern in your application or switch to the legacy parser 
implementation with 'spring.mvc.pathmatch.matching-strategy=ant_path_matcher'.

我已经将spring.mvc.pathpattern.matching-strategy=ant_path_matcher 添加到application.properties 文件中,但它不起作用。

【问题讨论】:

  • 您能否发布您的配置以查看更多详细信息。虽然基本上你不能使用所有匹配的通配符 ** 后跟 hardcdoed 文字和另一个通配符。
  • 这是我的配置:webSecurity.ignoring().antMatchers("/token/**", "/v1/token/**", "/v2/token/**", " /v2/authenticate/**", "/v3/api-docs/**", "/swagger-ui.html", "/swagger-ui/index.html");
  • 我无法从提供的错误中找到匹配器。您也可以发布堆栈跟踪吗?并将您的配置添加到您的答案中。如果堆栈跟踪告诉您一行代码,请也包括它们。
  • 这是由于spring 5.3.x upgrade... 解决方案:或设置该属性,或找到(请!)这个通配符,并替换它们(用更合适的东西)。 non-resolved-duplicate
  • ..springfox 还是 springdoc??

标签: spring spring-boot spring-mvc spring-security


【解决方案1】:

spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER 将此添加到 application.properties 中为我工作

【讨论】:

    猜你喜欢
    • 2021-11-15
    • 2022-01-21
    • 2021-01-10
    • 2021-02-26
    • 2021-10-14
    • 2021-01-17
    • 1970-01-01
    • 1970-01-01
    • 2020-12-15
    相关资源
    最近更新 更多