一般服务消费者有这么几种,HttpClient、Feign、Ribbon。这里我们介绍下Feign

服务器提供者

controller

springboot结合Feign,实现服务消费

这里Controller里面定义的方法就是服务提供者提供的接口API

服务消费者 

pom.xml

  <!-- 集成Feign -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
            <version>${spring.cloud.version}</version>
        </dependency>

定义Fegin请求接口类

springboot结合Feign,实现服务消费

Application.class

springboot结合Feign,实现服务消费 

Controller调用

springboot结合Feign,实现服务消费 

测试,请求成功

springboot结合Feign,实现服务消费 

相关文章:

  • 2021-06-08
  • 2021-09-02
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2022-01-15
猜你喜欢
  • 2021-11-03
  • 2022-12-23
  • 2021-07-21
  • 2022-01-11
  • 2021-08-14
  • 2021-08-02
相关资源
相似解决方案