SpringBoot 整合swagger报错Failed to start bean ‘documentationPluginsBootstrapper‘;

SpringBoot2.6.x以后,默认请求路径匹配策略从AntPathMatcher变为PathPatternParser,导致报错。解决方法是在application.properties或application.yml中设置spring.mvc.pathmatch.matching-strategy为ant_path_matcher,或者将SpringBoot版本降至2.6.0以下。
摘要由CSDN通过智能技术生成

报错原因:

由于Spring Boot 2.6.x 请求路径与 Spring MVC 处理映射匹配的默认策略从AntPathMatcher更改为PathPatternParser。所以需要设置spring.mvc.pathmatch.matching-strategy为ant-path-matcher来改变它。

解决方法:

方案一(推荐):

修改SpringMVC路径匹配规则,在配置文件application.properties文件中添加以下代码spring.mvc.pathmatch.matching-strategy=ant_path_matcher

若配置文件为application.yml,则添加以下代码

spring:

        mvc:

                pathmatch:

                         matching-strategy: ant_path_matcher

方案二:

将pom.xml依赖中的Spring Boot 版本号修改到2.6.0以下

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>2.5.6</version> <relativePath/>

</parent>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值