【发布时间】:2020-10-06 13:19:54
【问题描述】:
我有最新的 Spring Boot 应用程序和 springdoc.swagger-ui。
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.2.32</version>
</dependency>
我的 application.properties 包含 springdoc.swagger-ui.path=/swagger-ui-openapi.html
当我通过 Intellij IDEA 运行应用程序时,http://localhost:8080/swagger-ui-openapi.html 将我带到http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config Swagger UI 页面加载成功。
但是,如果我通过命令行启动应用程序:“java -jar my-app.jar”,我在浏览器中得到 404,并且在尝试访问 http://localhost:8080/swagger-ui-openapi.html 时出现日志“圆形视图路径 [错误]”中的错误 它会将我重定向到http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config
javax.servlet.ServletException: Circular view path [error]: would dispatch back to the current handler URL [/error] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
但是,http://localhost:8080/v3/api-docs 是可访问的,并且架构在此地址可用。
我该如何解决这个问题?
【问题讨论】:
-
你需要
swagger-annotations依赖吗?删除后运行您的应用程序。可能导致依赖冲突 -
@Suraj 你好!尝试依赖和不依赖 - 结果相同。此外,我想如果是依赖冲突,从 IDEA 运行时也会重现该问题,但事实并非如此。
-
我尝试了一个使用这两个依赖项的示例应用程序,它工作正常。看起来像其他问题
标签: spring-boot swagger-ui springdoc springdoc-openapi-ui