随笔分类 -  spring / springcloud

摘要:默认 filter 默认的有 38 个,分为5组:请求头、请求参数(查询字符串)、响应头、前缀和路径、其他,作用都不是很大,挑几个举个例 # 请求和响应 filter - id: test_my_consumer uri: http://localhost:8082 predicates: - Pa 阅读全文
posted @ 2024-09-05 13:47 CyrusHuang 阅读(3) 评论(0) 推荐(0) 编辑
摘要:spring: cloud: gateway: routes: - id: test_my_provider # 自定义,全局唯一即可 uri: http://localhost:8081 # 实际调用的地址 predicates: - Path=/test/** # 请求匹配规则 - id: te 阅读全文
posted @ 2024-09-05 13:47 CyrusHuang 阅读(4) 评论(0) 推荐(0) 编辑
摘要:服务提供者 服务消费者 网关 启动服务能看到这三个服务 测试,访问 my-provider-test 测试,my-consumer-test 通过 Feign 远程调用 my-provider-test 阅读全文
posted @ 2024-09-05 13:46 CyrusHuang 阅读(1) 评论(0) 推荐(0) 编辑
摘要:Feign 注册到容器 和 springboot 自动配置原理类似,在 springboot 启动时会扫描到 EnableFeignClients 注解,这个注解导入了一个 FeignClientsRegistrar 类 @Retention(RetentionPolicy.RUNTIME) @Ta 阅读全文
posted @ 2024-09-05 13:46 CyrusHuang 阅读(11) 评论(0) 推荐(0) 编辑
摘要:@EnableFeignClients 注解配置项 @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) @Documented @Import({FeignClientsRegistrar.class}) public @i 阅读全文
posted @ 2024-09-05 13:46 CyrusHuang 阅读(1) 评论(0) 推荐(0) 编辑
摘要:需要建两个工程,一个是服务提供者,一个是服务调用者 服务提供者 一个普通的 nacos 服务,增加一个 controller 方法即可,上一篇文章刚说了,这里简单说下 <!-- 服务提供者不调用其他服务,所以只需要注册到 nacos 的依赖 --> <dependency> <groupId>com 阅读全文
posted @ 2024-09-05 13:46 CyrusHuang 阅读(2) 评论(0) 推荐(0) 编辑
摘要:springboot 的各种 starter 会根据 SPI 机制,读取 META-INFO/spring.factories 文件,自动注册一些 bean,spring-cloud-starter-alibaba-nacos-discovery 的 spring.factories 如下: org 阅读全文
posted @ 2024-09-05 13:45 CyrusHuang 阅读(5) 评论(0) 推荐(0) 编辑
摘要:下载和安装 国内的软件,去官网下就行了,下载好后到其 bin 目录执行命令 startup.cmd -m standalone 服务就会启动 浏览器访问,能访问到 nacos 界面 小试牛刀 工程导入依赖 <!-- 当前服务注册到 nacos 需要 --> <dependency> <groupId 阅读全文
posted @ 2024-09-05 13:45 CyrusHuang 阅读(3) 评论(0) 推荐(0) 编辑
摘要:下载安装 下载地址:https://developer.hashicorp.com/consul/install?product_intent=consul 解压出来只有个 exe 文件,在这个目录打开 shell,consul --version 查看版本,consul agent -dev 开发 阅读全文
posted @ 2024-09-05 13:44 CyrusHuang 阅读(4) 评论(0) 推荐(0) 编辑
摘要:springcloud 和 springboot https://spring.io/projects/spring-cloud#overview 更详细的 https://github.com/spring-cloud/spring-cloud-release/wiki/Supported-Ver 阅读全文
posted @ 2023-05-24 17:32 CyrusHuang 阅读(23) 评论(0) 推荐(0) 编辑