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,并直接请求了。

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


打完收工!

相关推荐
MetaLite21 分钟前
全网最好的SpringBoot接口请求对象设计
java·spring boot·后端
摇滚侠1 小时前
《Spring Boot 3:高级与架构设计》第 2 章 IOC容器的高级机制 BeanFactoryPostProcessor 个人理解 6
java·spring boot·笔记·后端
xcl09252 小时前
宠物商城社交托运购物系统开发实战:从架构设计到完整实现指南
java·spring boot
没差c2 小时前
RetrofitClient写接口、导包、配置、路径
java·spring boot·okhttp
RuoyiOffice3 小时前
SpringBoot+Vue3 节日主题换肤实战:一条参数换全站配色,节后自动还原
spring boot·vue3·spring boot 3·vben admin·ruoyi office·节日主题·换肤方案
摇滚侠3 小时前
《Spring Boot 3:高级与架构设计》第 2 章 IOC容器的高级机制 Environment 个人理解 4
java·spring boot·笔记·后端
遨游DATA4 小时前
Spring 接口返回 errorMessage=null:如何排查二次异常覆盖原始业务错误
spring boot·异常处理·接口排障
+VX:Fegn08955 小时前
计算机毕业设计|基于springboot + vue图书借阅管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
星光开发者5 小时前
基于Spring Boot的充电桩管理系统的设计与实现-计算机毕设【课程设计】57105
vue.js·spring boot·vscode·mysql·django·php·express
+VX:Fegn089515 小时前
计算机毕业设计|基于springboot + vue蛋糕店管理系统(源码+数据库+文档)
前端·数据库·vue.js·spring boot·课程设计