Can't read swagger JSON from http://localhost:8080/Test/api-docs

时间:2022-11-16 09:20:32

新手入坑Swagger,搜了下网上博客,各种整合费时费力。弄出来竟然报错:

Can't read swagger JSON from http://localhost:8080/Test/api-docs

只能说博主水平参差不齐,好多只写了部分步骤,隐藏了一些操作。因此让我们这种小白坑了又坑!感慨,一万句MMP

解决方法一:

Tomcat 的server.xml文件配置。修改编码格式 加上URIEncoding="UTF-8"

Can't read swagger JSON from http://localhost:8080/Test/api-docs

加上URIEncoding="UTF-8"

Can't read swagger JSON from http://localhost:8080/Test/api-docs

解决方法二:

修改index.html中的url地址。当你的tomcat配置启动加入了项目名cardProject,地址为url = "http://localhost:8080/cardProject/api-docs"

否则地址如下:url = "http://localhost:8080/api-docs" ,我就没加项目名

其实你如果报上面的错误,证明你离成功只差一步了。

Can't read swagger JSON from http://localhost:8080/Test/api-docs

Can't read swagger JSON from http://localhost:8080/Test/api-docs

成功示例:

Can't read swagger JSON from http://localhost:8080/Test/api-docs