问题描述
1、OpenApi官网
2、根据官网步骤引入依赖
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.4.4</version>
</dependency>
3、启动项目,访问 http://server:port/context-path/swagger-ui.html 该UI界面
启动日志报错:
4、问题原因:界面路径未找到。
问题解决
官网中有这么一句话:the OpenAPI description will be available at the following url for json format: http://server:port/context-path/v3/api-docs,后面这部分就是以JSON的方式展示,访问后正常展示,说明数据接口提供正常。
这里的解决思路是不使用依赖中自带的UI,使用github上的swagger项目的界面,并更改访问的路径为本项目的api-docs的路径。
点击进入下载地址
下载完成后将项目中的dist文件夹下的所有文件复制到resources/static/swagger下,如图所示:
然后修改index.html中的url,修改访问的路径。
url: “http://localhost:8087/v3/api-docs”。42行位置
接下来启动项目,并进入到 http://server:port/context-path/swagger/index.html。这样界面就展示出来了,如下: