You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot集成Swagger访问swagger-ui.html报ServerWebExchange 500错误

问题根因

你的项目为Spring WebFlux 响应式微服务,全局排除了Spring WebMVC相关依赖,却错误引入了适配WebMVC的springdoc组件,导致运行时依赖不兼容,触发构造方法找不到的异常。

解决方案

按以下步骤修改即可:

  • 删除错误依赖:移除build.gradle中如下配置行
    implementation('org.springdoc:springdoc-openapi-webmvc-core:1.5.9')
    
  • 新增WebFlux适配的springdoc依赖
    implementation('org.springdoc:springdoc-openapi-webflux-ui:1.5.9')
    
  • 可选:如果需要保留/docs/前缀的访问路径,在application.yml/application.properties中添加如下配置
    springdoc:
      swagger-ui:
        path: /docs/swagger-ui.html
      api-docs:
        path: /docs/v3/api-docs
    
  • 清理项目构建缓存,重新打包启动服务后即可正常访问Swagger页面。

内容的提问来源于stack exchange,提问作者Abu Turab Munir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.27 19:45:05