2023-07-13 09:01:39 容器在启动过程中会找到所有@FeignClient的接口类,然后将这些类注册为容器Bean,而每一个Feign客户端对应的是FactoryBean对象FeignClientFactoryBean。 环境:Spring Cloud 2021.0.7 + Spring Boot 2.7.12 配置依赖 maven依赖 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-loadbalancer</artifactId> </dependency> <dependencyManagement> <dependencies> <dependency>...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Articles by Request.Options options
feign自定义负载到指定ip_feignclient指定ip_不想记的博客-CSDN博客
项目背景:目前使用的springcloud微服务架构,开发人员本地联调过程中,会用到许多并非自己开发的微服务支持。但是这样就需要启动多个应用,严重影响开发效率。现在架构组讨论写一个feign重负载,可以指定一次请求负载到具体ip。 大致想法:重写feign的负载均衡客户端LoadBalancerFeignClient,每次请求会执行excute方法,在excute方法中获取指定ip,替换feign已经负载好的ip。 遇到问题:配置类没加getset方法,导致无法读取配置文件;DiscoveryClient获取服务列表用getApplication方法,之前用的getInstance获取不到;版本问题,10.7.4feign-core版本拿到的url是ip,需要将ip替换为applicationname,否则调用多个feignclient会报错,具体原因还没扒出来。 上代码: 重写的负载客户端: @Slf4j public class FeignReBalancer extends LoadBalancerFeignClient { private Client delegate;...
Show More
loading
Actions
Is this you?
As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.Get in touch with Request.Options
Contact Request.Options, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack