我有一个依赖于 springdoc-openapi 的 spring boot 应用程序 (2.5.6)。 但是,启动 swagger-ui (http://localhost:8080/v1/swagger-ui/index.html) 不起作用。 调试日志表明 index.html 不存在。 找不到 index.html 的原因可能是什么?
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.8</version>
</dependency>
应用程序.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"
最佳答案
我找到了问题的原因。 application.yaml 中未设置上下文路径。
http://localhost:8080/v1/swagger-ui/index.html
添加servlet : context-path后,渲染swagger-ui
server:
port: 8080
servlet:
context-path: "/${spring.application.api-version}"
关于java - spring springdoc-openapi : swagger-ui/index. 找不到html status=404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72317932/