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

Spring Boot 3集成Springdoc无OpenAPI Bean时Swagger UI 404问题

Spring Boot 3中springdoc-openapi-ui 404问题解决

你的问题核心是版本兼容性不匹配:springdoc-openapi-ui 1.8.0是为Spring Boot 2设计的,无法在Spring Boot 3环境中正常工作。Spring Boot 3需要使用springdoc-openapi的2.x系列版本。

解决步骤:

  1. 更新pom.xml中的springdoc依赖版本
    将原有的springdoc-openapi-ui依赖替换为适配Spring Boot 3的2.x版本,比如对应Spring Boot 3.3.x的2.6.0版本:
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
    <version>2.6.0</version>
</dependency>

注:springdoc版本与Spring Boot版本存在对应关系,比如Spring Boot 3.0.x对应springdoc 2.0.x,3.1.x对应2.1.x,3.2.x对应2.2.x,3.3.x对应2.6.x,确保版本匹配即可。

  1. 启动应用后访问正确路径
    更新依赖并重启应用后,访问默认的Swagger UI路径:http://localhost:8080/swagger-ui.html即可正常打开界面,无需额外声明OpenAPI Bean。

可选配置(自定义路径)

如果需要修改默认的Swagger UI路径,只需在application.properties中添加配置:

springdoc.swagger-ui.path=/custom-swagger.html

这样修改后,就能像Spring Boot 2时期一样自动生成Swagger端点,无需手动配置OpenAPI Bean。

内容的提问来源于stack exchange,提问作者Cagepi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 06:36:06