【问题标题】:not allowed to read the swagger of a microservice from the gateway不允许从网关读取微服务的招摇
【发布时间】:2021-11-13 22:09:31
【问题描述】:

网关是由 jhipster 7.0.1 生成的,我添加了依赖项 io.springfox 的“springfox-boot-starter”。

<dependency>
     <groupId>io.springfox</groupId>
     <artifactId>springfox-boot-starter</artifactId>
     <version>3.0.0</version>
</dependency>
<dependency>
     <groupId>io.springfox</groupId>
     <artifactId>springfox-swagger-ui</artifactId>
     <version>3.0.0</version>
</dependency>

在 ui 中,我可以看到网关文档,还可以看到架构中的微服务,但是当我尝试单击微服务时,出现以下错误

未能加载 API 定义。

获取错误 未经授权的 http:///services//v3/api-docs

【问题讨论】:

  • 为什么要添加依赖“springfox-boot-starter”?网关中的 Swagger-ui 应该开箱即用
  • 最初我在链接 /swagger-ui.html 上使用默认配置 jhipster 寻找 swagger,但我遇到了 401 错误。所以我读了一篇关于如何在 springboot 中添加 swagger 的教程,这是我得到的建议

标签: swagger jhipster spring-cloud swagger-ui jhipster-gateway


【解决方案1】:

我能够解决我的问题,诀窍是在网关级别路由请求会要求令牌,当它没有看到它时,它会返回异常。所以我所做的不是返回异常,而是返回一个空测试,一切顺利

【讨论】:

    猜你喜欢
    • 2018-09-11
    • 1970-01-01
    • 2017-11-22
    • 1970-01-01
    • 2018-07-16
    • 2017-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多