当前位置: 首页 > article >正文

swagger2.9.2 和 springboot3.3.4版本冲突问腿

swagger2.9.2 和 springboot3.3.4版本冲突问腿

问题描述:当我们使用 swagger 2.9.2版本的时候,如果恰好我们使用的 springboot 版本是3.x版本,会出现启动报错的问题

解决办法:直接使用swagger 3.x 版本和 springboot 3.x 版本

解决步骤:

1.导入swagger3.x版本的maven依赖

在这里插入图片描述

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
            <version>2.2.0</version>
        </dependency>
2.在config包中加入swaager配置类

在这里插入图片描述

package com.example.demo.config;

import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {
    @Bean
    public OpenAPI springShopOpenAPI() {
        return new OpenAPI()
                .info(new Info().title("标题")
                        .contact(new Contact())
                        .description("我的API文档")
                        .version("v1")
                        .license(new License().name("Apache 2.0").url("http://springdoc.org")))
                .externalDocs(new ExternalDocumentation()
                        .description("外部文档")
                        .url("https://springshop.wiki.github.org/docs"));
    }
}

3.启动项目访问swagger
http://localhost:8080/swagger-ui/index.html#/

在这里插入图片描述


http://www.kler.cn/news/343474.html

相关文章:

  • 线控底盘技术介绍
  • Selenium WebDriver和Chrome对照表
  • 用AI构建小程序需要多久?效果如何?
  • Redis:set类型
  • 命令 首选项:打开用户设置(json) 导致错误 文件似乎是二进制文件,不能作为文本打开
  • Qt Qml Map-地图绘制点与圆的切线
  • 火山引擎边缘智能×扣子,拓展AI Agent物理边界
  • javascript 自定义多选框实现 ag-grid中没有原生多选框
  • 物理学基础精解【67】
  • 通知系统的设计方案
  • 项目 多人对话
  • 动态规划-路径问题——174.地下城游戏
  • bclinux安装minio和mc及从服务器上下载文件
  • C# Random类详解:生成随机数的实用指南
  • Python网络爬虫从入门到实战
  • 【大模型】RMS Normalization原理及实现
  • 安装Node.js环境,安装vue工具(最佳实践)
  • 【软件测试】最佳软件测试基础入门教程
  • urllib库的使用
  • JAIN SLEE 服务创建过程 (创建一个服务)