首页 > 编程知识 正文

gateway设置为多少,网关是多少

时间:2023-05-04 14:27:37 阅读:144474 作者:3838

文章目录1.yml配置2 .创建配置类(在代码中注入了RouteLocator的Bean ) ) ) ) ) ) )。

1.yml配置spring : application : name : cloud-gateway cloud : gateway : discovery : locator : enabled 3360 true #妈妈虽然没有固定规则,但要求是唯一的。 服务名称# uri :3358根据本地主机:8001 #提供服务的路由地址uri : lb ://cloud-payment-service # 推荐根据提供服务的路由地址predicates3360-path路径匹配的路由- id : payment _ Routh2# payment _ route #路由的id为固定规则服务名称# uri :3358根据本地主机:8001 #提供服务的路由地址uri : lb ://cloud-payment-service # 建议提供匹配服务的路由地址predicates3360-path如果断言,则路径匹配的进度路由#-after=2020-02-21t 15336051336037.48508:00 [ zzyy#-headeent d #请求标头具有X-Request-Id属性,值为整数的正则表达式2 .配置类(描述向代码中注入路由定位符的Bean )的配置访问id配置为path的*地址http://localhost:9527/guonei时,自动访问地址http://news.Baidu.com/Guo nei * @ param * @ return * @ beanpublicroutelocatorcustomroutelocator (routelocatorbuilderroutelocatorbuilder )/*是额yml配置的routes */routelocatorbuildelder 这是您希望路由的网站:http://news.Baidu.com/guoneiroutes.route (path _ route _ atguigu ',r-r.path return routes } /** *为path_route_atguigu2设置了路由规则。 *访问地址http://localhost:9527/guoji时,地址http://news.Baidu.com/Guo nei * @ param * @ return */@ beanpublicroutelocatorcustomroutelocator2(routelocatorbuilderbuilder (routelocatorbuilder.builder routes=builder.rouilder 2 (,r-r.path )/guoji ).uri ) ) http://news.baidu.com/guoji ) ) return routes.build (; }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。