Spring Boot更换Spring fox为Springdoc

文章目录


项目场景

由于项目中使用Spring fox已经不维护更新了,代码扫描,扫出问题,需要将Spring fox更换为Spring Doc。

由于我们封装的框架有个配置需要关掉,否则就会查看相关依赖,这个就不展示了。


引入

将将Spring fox依赖更换为Spring Doc

复制代码
implementation 'org.springdoc:springdoc-openapi-ui:1.6.9'

使用

使用就比较简单了,直接上配置就好了。

java 复制代码
@OpenAPIDefinition(
        info = @Info(
                    title = "SWAGGER - ${spring.profiles.active:prod} " ,
                    version = "v0.0.1",
                    description = "API Resources & Documentation",
                    contact = @Contact(
                        name="FLI86", email = "***"
                    )
        ),
        security = @SecurityRequirement(name = "SWAGGERAuthorize")
)
@SecuritySchemes({@SecurityScheme(
        name = "SWAGGERAuthorize",
        type = SecuritySchemeType.HTTP,
        description= "JWT认证",
        scheme="bearer",
        bearerFormat="JWT",
        in= SecuritySchemeIn.HEADER
)})
@Configuration
public class SpringDocConfiguration {
}

说明

  • @SecurityRequirement的name其实就是引用,引用的就是@SecuritySchemes里面的name,所以这两个要保持一致。
  • 因为我们是要用到token,所以在swagger里面配置好token之后,这边就能填入token,并直接请求了。

页面就不做展示了,涉及公司业务


打完收工!

相关推荐
学长毕设8 小时前
基于SpringBoot智慧养老服务平台设计与实现-附源码
java·spring boot·后端
千寻技术帮10 小时前
10454_基于Springboot的企业购销链管理系统
spring boot·mysql·vue·毕业设计·进销存
Forget the Dream11 小时前
Spring AI 2.0 系列(二):第一个 ChatClient——从注入到一次完整调用
java·人工智能·spring boot·ai·springai
她的男孩13 小时前
设计器能拖抄送,一点发布却报 flowable-servicetask-invalid-type:Forge Admin 部署前改写节点属性
spring boot·低代码·工作流引擎
学长毕设1 天前
基于SpringBoot社区快递驿站物流配送系统-附源码
java·spring boot·后端
雾隐隐o1 天前
优搭校园 01|项目概览、技术选型与初始化
spring boot·mysql·vue
雪芽蓝域zzs2 天前
第 10 章:Maven 打包
spring boot
RuoyiOffice2 天前
SpringBoot3+Vue3 采购到付款:ERP、WMS与财务如何按同一来源协同
java·spring boot·架构·vue
企业数字化笔记2 天前
报表上线怎么对账?口径回归、权限抽检与差异定位
java·spring boot·mysql
乌暮2 天前
少写重复 CRUD:用大白话搞懂 MyBatis-Plus
java·开发语言·spring boot·面试·mybatis