【SpringCloud】03-Gateway网关

embedded/2024/10/22 3:06:19/

1. Gateway

网关:负责请求的路由、转发、身份校验。
在这里插入图片描述

2. Spring Cloud Gateway

在这里插入图片描述

  1. 依赖
<!--网关--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency><!--nacos 服务注册发现--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><!--openFeign--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency><!--负载均衡器--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-loadbalancer</artifactId></dependency><!--OK http 的依赖 --><dependency><groupId>io.github.openfeign</groupId><artifactId>feign-okhttp</artifactId></dependency>
  1. yaml配置
server:port: 8080
spring:cloud:nacos:server-addr: ***:8848gateway:routes:- id: item-serviceuri: lb://item-servicepredicates:- Path=/items/**,/search/**- id: cart-serviceuri: lb://cart-servicepredicates:- Path=/carts/**- id: user-serviceuri: lb://user-servicepredicates:- Path=/users/**,/addresses/**- id: trade-serviceuri: lb://trade-servicepredicates:- Path=/orders/**application:name: gateway

3. 断言

在这里插入图片描述

4. 过滤器

在这里插入图片描述

spring:cloud:nacos:server-addr: ***:8848gateway:routes:- id: item-serviceuri: lb://item-servicepredicates:- Path=/items/**,/search/**filters:- AddRequestHeader=truth, no one- id: cart-serviceuri: lb://cart-servicepredicates:- Path=/carts/**- id: user-serviceuri: lb://user-servicepredicates:- Path=/users/**,/addresses/**- id: trade-serviceuri: lb://trade-servicepredicates:- Path=/orders/**default-filters:- AddRequestHeader=truth, no one

http://www.ppmy.cn/embedded/129451.html

相关文章

基于jsp+Spring boot+mybatis的图书管理系统设计和实现

基于jspSpring bootmybatis的图书管理系统设计和实现 &#x1f345; 作者主页 网顺技术团队 &#x1f345; 欢迎点赞 &#x1f44d; 收藏 ⭐留言 &#x1f4dd; &#x1f345; 文末获取源码联系方式 &#x1f4dd; &#x1f345; 查看下方微信号获取联系方式 承接各种定制系统 …

5G NR Test UE FR1

什么是5G NR Test UE FR1套件&#xff1f; 5G NR Test UE FR1套件完全符合3GPP Release 15标准&#xff0c;用于模拟5G用户设备(UE)&#xff0c;并可在连接到gNodeB时提供实时性能信息。凭借100 MHz的带宽和4x2 MIMO&#xff0c;该套件可以在每个5G频段上测试组件、子系统和/或…

基于微信小程序二手物品调剂系统设计与实现

文章目录 前言项目介绍技术介绍功能介绍核心代码数据库参考 系统效果图文章目录 前言 文章底部名片&#xff0c;获取项目的完整演示视频&#xff0c;免费解答技术疑问 项目介绍 二手物品调剂系统是一种在线平台&#xff0c;旨在促进用户之间的二手物品交易。该系统提供了一个…

Erric Gamma 关于resuable code的采访

采访地址 The risk of speculating Bill Venners: The GoF book says, “The key to maximizing reuse lies in anticipating new requirements and changes to existing requirements, and in designing your systems so they can evolve accordingly. To design a system s…

网络空间指纹:新型网络犯罪研判的关键路径

前言 新型网络犯罪是指利用计算机技术和互联网平台进行犯罪活动的一类犯罪行为。它涵盖了一系列使用网络和数字技术进行非法活动的行为&#xff0c;如网络钓鱼、网络诈骗、恶意软件攻击、黑客入侵、数据泄露、网络色情和社交网络犯罪等。 随着当前打击治理新型网络犯罪博弈态…

面试头棒-Java如何判断两个对象是否相等

在Java中&#xff0c;判断两个对象是否相等通常涉及两个层面的比较&#xff1a;引用相等&#xff08;也称为身份相等&#xff09;和内容相等&#xff08;也称为值相等&#xff09;。 引用相等&#xff08;Identity Equality&#xff09;&#xff1a; 使用 运算符。如果两个引…

React 高级阶段学习计划

React 高级阶段学习计划 目标 深入理解React的渲染机制和性能优化。学会代码分割和懒加载。掌握单元测试和集成测试。学习TypeScript与React的结合。 学习内容 性能优化 React.memo React.memo&#xff1a;用于优化函数组件的性能&#xff0c;避免不必要的重新渲染。示例…

【Linux】内存文件系统的I/O、重定向

文章目录 1. 系统中的文件2. 回顾C中的文件接口3. 文件类的系统调用3.1 open3.2 文件描述符 4. IO的基本过程5.重定向5.1 引入重定向5.2 系统中的重定向接口 6. 缓冲区问题7. 简单版shell的实现 1. 系统中的文件 在学习完Linux权限后&#xff0c;我们清楚的知道&#xff1a;文…