记一次springboot2.6.x整合swagger3报错

  1. 如图pom引入了swagger3的依赖在这里插入图片描述
    启动程序报错
    在这里插入图片描述

  2. 根据网上的文章找到解决方法
    在application.yml文件中新增

    spring:
        mvc:
          pathmatch:
            matching-strategy: ant_path_matcher
    

但是这种方法有隐患
只有在不使用 Spring Boot 的执行器时,此功能才起作用。
无论配置的匹配策略如何,执行器将始终使用基于路径模式的解析 ( 也就是默认策略 ) 。
如果您想在 Spring Boot 2.6及更高版本中将其与执行器一起使用,则需要对 Springfox 进行更改。
3. 最终解决方法
新建swagger3配置类


import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值