• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

SpringCloud整合OpenFeign时@FeginClient注入错误

武飞扬头像
shenguoxiao
帮助1

No bean found of type interface org.springframework.cloud.openfeign.Targeter for 服务名.

  1. openfeign的版本要跟着SpringCloud走

  1.  
    <!-- 父pom springcloud 依赖-->
  2.  
    <dependency>
  3.  
        <groupId>org.springframework.cloud</groupId>
  4.  
        <artifactId>spring-cloud-dependencies</artifactId>
  5.  
        <version>${springcloud.version}</version>
  6.  
        <type>pom</type>
  7.  
        <scope>import</scope>
  8.  
    </dependency>
  9.  
    引入时不用加版本号
  10.  
    <dependency>
  11.  
    <groupId>org.springframework.cloud</groupId>
  12.  
    <artifactId>spring-cloud-starter-openfeign</artifactId>
  13.  
    </dependency>
  1. 注意包扫描路径的问题,如果写的包路径不能被Springboot默认路径扫描,则@EnableFeignClient(basePackages=手动加FeignClient的包路径)

  1. feign配置如果引入了断路器要加入相关的依赖

  1.  
    feign:
  2.  
    #开启feign断路器 依赖hystrix包
  3.  
    circuitbreaker:
  4.  
    enabled: true
  5.  
    client:
  6.  
    config:
  7.  
    default:
  8.  
    connect-timeout: 60000
  9.  
    read-timeout: 60000
  10.  
    <dependency>
  11.  
    <groupId>org.springframework.cloud</groupId>
  12.  
    <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
  13.  
    </dependency>

我就是加断路器的时候,忘记引入hystrix包,导致@FeignClient注入不了Targeter

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgbhbbg
系列文章
更多 icon
同类精品
更多 icon
继续加载