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

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


打完收工!

相关推荐
customer087 小时前
【开源免费】基于SpringBoot+Vue.JS体育馆管理系统(JAVA毕业设计)
java·vue.js·spring boot·后端·开源
计算机-秋大田10 小时前
基于微信小程序的电子竞技信息交流平台设计与实现(LW+源码+讲解)
spring boot·后端·微信小程序·小程序·课程设计
customer0813 小时前
【开源免费】基于SpringBoot+Vue.JS景区民宿预约系统(JAVA毕业设计)
java·vue.js·spring boot·后端·开源
精通HelloWorld!17 小时前
使用HttpClient和HttpRequest发送HTTP请求
java·spring boot·网络协议·spring·http
拾忆,想起19 小时前
如何选择Spring AOP的动态代理?JDK与CGLIB的适用场景
spring boot·后端·spring·spring cloud·微服务
customer0821 小时前
【开源免费】基于SpringBoot+Vue.JS美食推荐商城(JAVA毕业设计)
java·vue.js·spring boot·后端·开源
一 乐21 小时前
基于微信小程序的酒店管理系统设计与实现(源码+数据库+文档)
java·数据库·vue.js·spring boot·微信小程序·酒店管理系统
小万编程1 天前
【2025最新计算机毕业设计】基于SpringBoot+Vue家政呵护到家护理服务平台(高质量源码,可定制,提供文档,免费部署到本地)
java·vue.js·spring boot·计算机毕业设计·java毕业设计·web毕业设计
XYu123011 天前
Spring Boot 热部署实现指南
java·ide·spring boot·intellij-idea
是小崔啊1 天前
Spring Boot - 数据库集成07 - 数据库连接池
数据库·spring boot·oracle