Spring Boot 3.0.0-SNAPSHOT集成springdoc-openapi-ui失败求助
Spring Boot 3.0.0-SNAPSHOT 中 springdoc-openapi-ui 无法正常工作的解决方案
核心问题:Spring Boot 3.x 基于Jakarta EE API,而你当前使用的
springdoc-openapi-ui 1.6.12仅适配Spring Boot 2.x(基于Java EE),API规范不兼容导致功能失效。修复方案:
升级springdoc依赖版本并更换依赖名:使用支持Spring Boot 3.x的版本(最低2.0.0+),同时Spring Boot 3.x对应的springdoc starter依赖名称已更新,修改配置如下:
id 'org.springframework.boot' version '3.0.0-SNAPSHOT' implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.2.0'若你的项目是WebFlux架构,替换为
springdoc-openapi-starter-webflux-ui即可。调整访问路径:新版springdoc在Spring Boot 3.x下的默认Swagger UI路径为
http://localhost:8080/swagger-ui/index.html,如果项目有/user上下文路径,访问地址改为http://localhost:8080/user/swagger-ui/index.html。
验证步骤:重启项目后访问调整后的路径,检查Swagger UI是否正常加载展示接口文档。
内容的提问来源于stack exchange,提问作者Ayshan Rzayeva
相关产品推荐
相关产品推荐

