Giter Club home page Giter Club logo

Comments (1)

zuihou avatar zuihou commented on May 22, 2024
  1. 在自己新建服务的服务增加接口后, 想要前端调用必须在网关增加一个新建服务的路由.
// 在naocs的 zuihou-gateway-server.yml  中加入:
        - id: demo
          uri: lb://zuihou-demo-server
          predicates:
            - Path=/demo/**
          filters:
            - StripPrefix=1
  1. 假设新建服务的端口是 8080, 浏览器访问新建服务的swagger页面, http://ip:8080/doc.html 观察能否访问到你新增的Controller接口.
  2. http://ip:8080/doc.html无法访问, 但postman 访问 http://ip:8080/xxxx(你自己写的接口) 能访问, 说明服务业务代码没问题, swagger 相关配置有问题.
// 修改 zuihou-demo-server.yml
zuihou:
  swagger:
    docket:
      demo:
        title: 演示服务
        base-package: com.github.zuihou.demo.controller    // 注意调整这里的包路径
  1. http://ip:8080/doc.html无法访问, 且 postman 访问 http://ip:8080/xxxx(你自己写的接口) 也无法访问, 可能是你服务没正常启动, 观察启动报错, 访问接口时的报错. 可能有以下情况:
    4.1. 报错404: server模块没有依赖controller模块, 启动能成功,但实际该服务在启动时, 没有加载到controller模块的代码, 故无法访问. 解决方式: 在server模块加入 controller模块的依赖.
    4.2. 报错访问xx没有xx权限: 接口请求成功了, 但该接口需要指定的权限,检测到当前访问用户没有权限. 解决方案1: @PreAuth(enabled = false) 禁用权限; 方案2: 给当前用户授权, 访问时,在请求头传递userid 参数. 参考: https://github.com/zuihou/zuihou-admin-cloud/issues/35
    4.3. 报错无法正确的解析json类型的参数: 参数传错了.
  2. http://ip:8080/doc.html (该页面是直接访问新建服务)能访问, 但通过网关访问swagger文档(http://ip:8760/api/doc.html)无法显示, 则参考第1步.

总结: 通过网关访问接口无法访问时,先验证直接访问业务服务是否正常.

  1. 若业务服务能正常访问,通过网关无法访问,就是网关的配置问题.
  2. 若通过网关能访问, 独立访问业务服务不行, 则是业务服务的问题.

from lamp-cloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.