spring-cloud-feign 相关问题

使用此标记可以获得与Spring云生态系统中Feign声明性REST客户端的使用相关的问题。

Spring Cloud OpenFeign 在调用端点时不发送音频/ogg 标头

我尝试通过 Spring Cloud Feign 客户端调用 API 发送音频 OGG 文件字节。 但我收到 400 Bad Request,错误如下: “error_message”:“OGG 标头...

回答 2 投票 0

fiegnclient 无法识别 Spring Boot application.properties 文件中提到的 server.servlet.context-path

我正在使用 feign 客户端调用另一个微服务的 api,其中我提到了 server.servlet.context-path ="some value" 和 spring.application.name="app name" 但在 feign 客户端中使用它时.. .

回答 1 投票 0

在没有负载均衡器的情况下,在application.properties中通过服务名称为@FeignClient提供URL

我想使用 Feign 客户端并通过服务名称在 application.properties 中提供 URL。 先决条件: 我使用 Spring Boot,并且依赖 Spring Cloud 中的 Feign: 我想使用 Feign 客户端并通过服务名称在 application.properties 中提供 URL。 先决条件: 我使用 Spring Boot,并且我依赖 Spring Cloud 中的 Feign: <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> 我启用了 Feign 客户端: @SpringBootApplication @EnableFeignClients public class MyApplication { public static void main(String[] args) { SpringApplication.run(MyApplication.class, args); } } 尝试: 1.代码中硬编码的 URL 我知道如何在代码中硬核 URL: @FeignClient(name = "some-service", url = "http://some-service.com/") public interface SomeServiceClient {} 但我想使用属性文件。 2.硬编码属性 我知道如何对属性进行硬编码以从属性中读取 URL: @FeignClient(name = "some-service", url = "${some-service.url}") public interface SomeServiceClient {} application.properties: some-service.url=http://some-service.com/ 这是一个更好的方法,但我想将属性名称与 Feign 客户端解耦。我只想使用name。 3.带负载平衡器的功能区 当我可以为 Ribbon 的负载均衡器指定 URL 列表(通过 Feign 客户端名称)时,我知道 Spring Cloud 提供了 Ribbon。 @FeignClient(name = "some-service") public interface SomeServiceClient {} application.properties: some-service.ribbon.listOfServers=http://some-service.com/ ribbon.eureka.enabled=false 注意:我必须禁用 Eureka(默认启用),因为我不需要 Eureka 服务器。我需要在我的应用程序中的 application.properties 中提供 URL。 依赖性: <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-ribbon</artifactId> </dependency> 这个解决方案似乎更好,因为代码中的 Feign 客户端仅包含 name(没有 URL 或 URL 的耦合属性名称)。这正是我想要得到的。 但在日志中我看到 Spring/Ribbon 为我运行负载均衡器: 2020-11-03 23:39:01.832 INFO 12168 --- [nio-8080-exec-2] c.netflix.config.ChainedDynamicProperty : Flipping property: some-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647 2020-11-03 23:39:01.892 INFO 12168 --- [nio-8080-exec-2] c.netflix.loadbalancer.BaseLoadBalancer : Client: some-service instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=some-service,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null 2020-11-03 23:39:01.908 INFO 12168 --- [nio-8080-exec-2] c.n.l.DynamicServerListLoadBalancer : Using serverListUpdater PollingServerListUpdater 2020-11-03 23:39:01.955 INFO 12168 --- [nio-8080-exec-2] c.netflix.config.ChainedDynamicProperty : Flipping property: some-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647 2020-11-03 23:39:01.970 INFO 12168 --- [nio-8080-exec-2] c.n.l.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client some-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=some-service,current list of Servers=[jsonplaceholder.typicode.com:443],Load balancer stats=Zone stats: {unknown=[Zone:unknown; Instance count:1; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;] },Server stats: [[Server:jsonplaceholder.typicode.com:443; Zone:UNKNOWN; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Thu Jan 01 01:00:00 CET 1970; First connection made: Thu Jan 01 01:00:00 CET 1970; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0] ]}ServerList:com.netflix.loadbalancer.ConfigurationBasedServerList@6a4bfe52 我不需要负载均衡器(我只有一个 URL)。如何禁用它并始终获得第一个listOfServers?也许有一种方法可以提供负载均衡器的自定义实现?或者至少禁用冗余负载均衡器的日志? 或者如何以其他方式为服务名称配置一个URL? 我阅读了文档,但没有找到解决方案: https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-feign.html https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-ribbon.html 我面临着同样的问题,您是否按照EnableFeignClients使得Spring无法加载上下文中的建议尝试了以下操作? spring.main.allow-bean-definition-overriding=true feign.client.config.some-service.url=http://some-service.com/ @mkczyk - 您对上述问题有任何解决方案吗?我面临着非常类似的问题 - springCloud 2021.09 、 Springboot 2.6.15 、 openFeign 、 Hystrix 和 Ribbon 等。

回答 2 投票 0

Feign客户端http连接问题

我使用feign客户端连接下游系统。最近下游系统发生了中断,但令人惊讶的是,一旦下游系统从我们的系统到下游系统的所有调用都开始超时

回答 1 投票 0

Spring OpenFeign Ogg 文件发送问题

我正在尝试通过java中的feign客户端将音频OGG文件字节发送到API端点,但我收到了400错误请求→“error_message”:“OGG标头尚未找到”。但如果文件是

回答 1 投票 0

Spring 生态系统和 OpenFeign 的错误

堆栈跟踪: java.lang.IllegalStateException:org.springframework.cloud.openfeign.FeignAutoConfiguration.cachingCapability 上的错误处理条件 在 org.springframework.boot.autoconfigure.

回答 3 投票 0

如何基于api接口在java\kotlin中自动生成Feign客户端?

我在 Spring Boot 中为我的下一个控制器提供了 api 接口 @RequestMapping(“/v1/资源”) @验证 接口资源Api { @Operation(summary = "获取资源") @

回答 1 投票 0

使用Feign创建SDK库

我有兴趣使用 Feign 为基于 Spring 的客户端创建一个 SDK 库到 Spring Boot 的 Restful 服务。 标准 Feign 用例似乎是一个暴露 API jar 工具的服务......

回答 1 投票 0

如何在Spring feign客户端中将多个图像作为@RequestPart传递?

我正在尝试使用 feign 客户端传递多个文件(图像)。但是,当我对 MultipartFile 列表或数组使用 @RequestPart 注释时,出现错误。对于单个 MultipartFil...

回答 1 投票 0

在 Spring-Cloud-Feign 上配置代理路由规划器

在Feign上配置代理路由规划器 我需要知道如何使用 Spring Boot REST 客户端在代理服务器后面发出请求。我可以使用 apache commons for REST 来完成此配置

回答 4 投票 0

Spring Cloud OpenFeign - 如何创建测试切片?

我有一个Feign客户端测试,我想设置一个测试片,比如@WebMvcTest,@DataJpaTest等。 例如,以下测试使用@SpringBootTest并加载所有应用程序

回答 3 投票 0

升级到Spring Boot 3后Feign请求返回400错误

在我的项目中有一个使用这种方法的假客户端 @PostMapping(路径 = "/docs/{docId}") ObjectDto createDocument(@PathVariable("docId") UUID docId, @RequestParam("userI...

回答 1 投票 0

Jackson用Feign无法反序列化Spring的org.springframework.data.domain.Sort

问题:假客户端对返回页面的 Spring boot Rest API 进行 API 调用无法反序列化该页面的排序属性。 Spring Boot:2.3.3.发布 春云飞……

回答 5 投票 0

bean“exampleService.FeignClientSpecification”无法注册。 Bean 已定义且覆盖已禁用

我的假客户端类和应用程序类如下。 @FeignClient(name = "ExampleService", 配置 = FeignClientConfig.class, url = "http://localhost:8091") 公共接口

回答 9 投票 0

Graphql 请求不是由 graphql 提供服务,而是由一般 Spring Rest 提供服务

我的 Spring Boot 应用程序公开了不同 API 集的 Rest 和 graphql 端点。 Rest 端点工作正常,但 graphql 请求也被视为休息并抛出 404...

回答 1 投票 0


多个Feign客户端超时配置

如果您喜欢使用配置属性来配置所有@FeignClient,您可以使用默认的feign名称创建配置属性。还可以根据特定的情况设置这些超时...

回答 2 投票 0

如果有手动添加的方法,Feign Client 不会代理接口继承的方法

在我的项目中,我有一个公共模块,其中包含根据 OpenAPI 规范生成的 API 接口: @Generate(value = "org.openapitools.codegen.languages.SpringCodegen") @验证 @Tag(name = "ACC...

回答 1 投票 0

从 application.yaml 读取 FeignClient url 不起作用

我正在尝试从 application.yaml 读取 Feign 客户端 url,我没有使用功能区。 Ribbon之前工作过,现在我迁移到Spring Boot 3.1.4和Spring Cloud 2022.0.3 @FeignClient(名称 = "新-

回答 1 投票 0

如何从 Feign 客户端获取准确的 Rest API 错误

我是 Spring Boot 上的 Feign Client 新手,所以请允许我。 我正在尝试使用下面的代码与 Feign Client 进行网络调用 有趣的 validateAccessToken(accessToken: String?): ResponseEntity...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.