1. spring:
    2. cloud:
    3. gateway:
    4. #设置路由:路由id、路由到微服务的uri、断言
    5. routes:
    6. - id: order_route #路由ID,全局唯一
    7. uri: http://localhost:8020 #目标微服务的请求地址和端口
    8. #配置过滤器工厂
    9. filters:
    10. - PrefixPath=/mall-order # 添加前缀 对应微服务需要配置context-path

    mall-order中需要配置

    1. server:
    2. servlet:
    3. context-path: /mall-order

    测试:http://localhost:8888/order/findOrderByUserId/1 ====》http://localhost:8020/mall-order/order/findOrderByUserId/1