简体   繁体   English

Spring springdoc-openapi:swagger-ui/index.html 找不到状态=404

[英]Spring springdoc-openapi : swagger-ui/index.html cannot be found status=404

I've a spring boot application (2.5.6) with a dependency on springdoc-openapi.我有一个依赖于 springdoc-openapi 的 spring boot 应用程序(2.5.6)。 However, launching swagger-ui (http://localhost:8080/v1/swagger-ui/index.html) doesn't work.但是,启动 swagger-ui (http://localhost:8080/v1/swagger-ui/index.html) 不起作用。 The debug logs are indicating that index.html is not present.调试日志表明 index.html 不存在。 What could be the reason that index.html is not found ?找不到 index.html 的原因可能是什么?

在此处输入图像描述

<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
    <version>1.6.8</version>
</dependency>

application.yaml应用程序.yaml

springdoc:
  swagger-ui:
    tagsSorter: alpha
    operations-sorter: alpha
    doc-expansion: none
    disable-swagger-default-url: true

logging:
  level:
    root: DEBUG

server:
  port: 8080

spring:
  application:
    name: fe-applic-app
    api-version: "v1"

在此处输入图像描述

Try swagger-ui.html instead of swagger-ui/index.html .尝试swagger-ui.html而不是swagger-ui/index.html In 60% of the cases swagger-ui.html redirects to its real location.在 60% 的情况下, swagger-ui.html会重定向到它的真实位置。

http://localhost:8080/v1/swagger-ui.html http://localhost:8080/v3/swagger-ui.html http://localhost:8080/v1/swagger-ui.html http://localhost:8080/v3/swagger-ui.html

I found the cause of the problem.我找到了问题的原因。 The context-path was not set in application.yaml.未在 application.yaml 中设置上下文路径。

http://localhost:8080/ v1 /swagger-ui/index.html http://localhost:8080/ v1 /swagger-ui/index.html

After adding servlet : context-path , swagger-ui is rendered添加servlet : context-path后,渲染 swagger-ui

server:
  port: 8080
  servlet:
    context-path: "/${spring.application.api-version}"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UnitTest 调用 /swagger-ui.html 导致 springdoc-openapi 404 - UnitTest call /swagger-ui.html results in a 404 for springdoc-openapi springdoc-openapi、swagger UI 中的 XML 示例 - XML examples in springdoc-openapi, swagger UI 使用 Spring 安全性启用 Swagger springdoc-openapi-ui (OpenAPI 3.0) - 无法访问 swagger-ui.html (401) - Enabling Swagger springdoc-openapi-ui (OpenAPI 3.0) with Spring Security - Cannot access swagger-ui.html (401) 如何在 swagger-UI 中的 index.html 中设置 url - How to set url in index.html in swagger-UI Java springdoc-openapi 在 Swagger UI 示例值中显示带有附加日期/时间字段的 LocalDateTime 字段 - Java springdoc-openapi show LocalDateTime field with additional date/time fields in Swagger UI Example Value Swagger 错误 Springboot Could not resolve view with name 'forward:/swagger-ui/index.html' - Swagger error Springboot Could not resolve view with name 'forward:/swagger-ui/index.html' swagger-ui 和 spring webflux 的 404 错误 - 404 error with swagger-ui and spring webflux springdoc-openapi-ui生成的swagger-ui中如何更改请求header中授权key的名称 - How to change the name of the authorization key in the request header in the swagger-ui generated by springdoc-openapi-ui springdoc-openapi swagger 不要带参数调用 - springdoc-openapi swagger don't make calls with parameters 如何在 spring-boot 中完全禁用 swagger-ui?(/swagger-ui.html 应该返回 404) - How to fully disable swagger-ui in spring-boot?(/swagger-ui.html should return 404)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM