Spring Cloud Feign + Sleuth + Zipkin - 需要原始请求

Spring Cloud Feign + Sleuth + Zipkin - original request is required

我有一个使用 Spring Cloud OpenFeign 的多服务应用程序。现在我必须在该应用程序中使用 zipkin。我记得当我有没有 Feign 的应用程序时,我只是在端口 9411 上添加了 Sleuth 和 Zipkin 启动器依赖项以及 运行 zipkin 服务器。之后 Zipkin 运行良好..但是现在,当我在我的应用程序中尝试使用 Feign 时,我得到了错误 500 "original request is required"。我猜当 Sleuth 添加跟踪信息时,Feign 在 headers 方面存在一些问题。你能帮我解决这个问题吗?

没有更多信息很难判断。但它可能与不兼容的库有关。你能 post 你的依赖项吗?

如果您使用 旧版本 的 okhttpclient 和 最新 spring cloud:greenwich 它可能会导致这个问题。

我正在使用 Greenwich.RELEASEokhttpclient:10.2.0,没有问题

使用下面的spring-boot依赖管理来下载适合云版的版本

    <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

我正在使用 Java 10,cloud.version 是 Finchley.SR2 和 sprinb-boot:2.2.0 和 spring-cloud -starter-openfeign :2.1.2.RELEASE。这个组合帮我解决了这个问题。

实际问题是 10.x.x 仅 feign-core 不工作,io.github.openfeign:feign-core:jar:9.7.0:compile 正在工作。

我在使用 java 11、springboot 2.3.0.RELEASE 和 spring-云版本 Greenwich.RELEASE 时遇到了这个问题。添加以下依赖项救了我:

    <dependency>
        <groupId>io.github.openfeign</groupId>
        <artifactId>feign-okhttp</artifactId>
        <version>10.2.0</version>
    </dependency>
    <dependency>
        <groupId>io.github.openfeign</groupId>
        <artifactId>feign-core</artifactId>
        <version>10.2.0</version>
    </dependency>

希望这对某人有所帮助。