feign访问微服务

Feign

  • 声明式REST客户端(伪RPC)
  • 采用基础接口的注解
  • 使用ribbon做负载均衡
/**
 * 访问接口
 */
@FeignClient(name = "client") // application.name
public interface ClientService {

    @GetMapping("home/hello")
    String helloClient();

}
@Autowired
private ClientService clientService;

@GetMapping("/helloFeign")
public String helloFeign() {
    String result = clientService.helloClient();
    return result;
}

猜你喜欢

转载自blog.csdn.net/butterballj/article/details/81178742