eureka_feign学习_1

我到现在都是看着代码来理解,没从网上找他的具体介绍啥的,所以理解可能有些问题,到时候再细细的看

创建feign模块

service-feign : Web、Eureka Discovery、Feign

创建yml

server:
  port: 8765
eureka:
  client:
    service-url:
      defaultZone : http://localhost:8761/eureka/
spring:
  application:
    name: service-feign

Application上除了添加@EnableDiscoveryClient,还要添加@EnableFeignClients

feign最关键的核心就是他的Service接口

在他的Service接口上添加@FeignClient来确定使用的是哪一个注册服务

@FeignClient(value = "service-hi")
public interface SchedualServiceHi {

    @RequestMapping(value = "/hi",method = RequestMethod.GET)
    String sayHiFromClientOne(@RequestParam(value = "name") String name);

}

然后,它会自动帮你跳转到service-hi服务的“/hi”接口。

原文地址:https://www.cnblogs.com/kongkongFabian/p/9973384.html