【问题标题】:FeignClient in spring boot 2Spring Boot 2 中的 FeignClient
【发布时间】:2018-09-17 18:05:01
【问题描述】:

我正在尝试从 spring boot 1.5 tio 2.0 迁移并遇到问题:我将 spring-cloud-netflix-core 的版本从 1.3.4.RELEASE 更改为2.0.1.RELEASE

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-netflix-core</artifactId>
        <version>2.0.1.RELEASE</version>
    </dependency>

很遗憾,feign 库导入失败:

import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.feign.FeignAutoConfiguration;
import org.springframework.cloud.netflix.feign.FeignClient;

新的 2.0.1 版本中没有库 .feign。我应该改用什么? (由于与 spring boot 自动配置冲突,不能离开旧的云版本)

【问题讨论】:

    标签: java spring spring-boot netflix-feign spring-cloud-feign


    【解决方案1】:

    自从2.x 发布以来,Spring Cloud 将 netflix 的 feign 类移到了他们自己的项目中。

    https://github.com/spring-cloud/spring-cloud-openfeign

    您需要使用正确的包更新重新导入

    org.springframework.cloud.openfeign

    【讨论】:

      【解决方案2】:

      从 2.X 版本开始需要将 feign 作为独立依赖导入:

      <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-starter-openfeign</artifactId>
          <version>2.0.1.RELEASE</version>
      </dependency>
      

      【讨论】:

        猜你喜欢
        • 2017-08-31
        • 1970-01-01
        • 2021-12-30
        • 2021-11-13
        • 1970-01-01
        • 2018-08-22
        • 1970-01-01
        • 2018-08-29
        • 2019-02-18
        相关资源
        最近更新 更多