当前位置: 首页 > 软件库 > 开发工具 > Java开发工具 >

Feign

Java HTTP 客户端库
授权协议 Apache
开发语言 Java
所属分类 开发工具、 Java开发工具
软件类型 开源软件
地区 不详
投 递 者 芮学
操作系统 跨平台
开源组织 Netflix
适用人群 未知
 软件概览

Feign 使得 Java HTTP 客户端编写更方便。

Feign 灵感来源于 Retrofit, JAXRS-2.0WebSocket,Feign 最初是为了降低统一绑定 Denominator 到 HTTP APIs 的复杂度,不管是否是 Restful 。

Feign 使用Jersey和CXF之类的工具为ReST或SOAP服务编写Java客户端。此外,Feign允许用户在诸如Apache HC之类的http库之上编写自己的代码。Feign通过可定制的解码器和错误处理功能,以最小的开销和代码将代码连接到http API,这些错误和错误处理可以写入任何基于文本的http API。

基础使用:

interface GitHub {
  @RequestLine("GET /repos/{owner}/{repo}/contributors")
  List<Contributor> contributors(@Param("owner") String owner, @Param("repo") String repo);
}
static class Contributor {
  String login;
  int contributions;
}
public static void main(String... args) {
  GitHub github = Feign.builder()
                       .decoder(new GsonDecoder())
                       .target(GitHub.class, "https://api.github.com");
  // Fetch and print a list of the contributors to this library.
  List<Contributor> contributors = github.contributors("netflix", "feign");
  for (Contributor contributor : contributors) {
    System.out.println(contributor.login + " (" + contributor.contributions + ")");
  }
}
  • 什么是Feign Feign是Spring Cloud Netflix组件中的一个轻量级RESTFULL的http服务客户端,实现了负载均衡和Rest调用的开源框架,封装了Ribbon和RestTemplate,实现了webservice的面向接口编程,进一步降低了项目的耦合度。 Feign内置了Ribbon,用来做客户端负载均衡调用服务注册中心的服务。 Feign本身并不支持SpringMVC的

  • 一 点睛 Feign是Netflix开发的声明式、模板化的HTTP客户端, Feign可以帮助我们更快捷、优雅地调用HTTP API。 在Spring Cloud中,使用Feign非常简单——创建一个接口,并在接口上添加一些注解,代码就完成了。Feign支持多种注解,例如Feign自带的注解或者JAX-RS注解等。 Spring Cloud对Feign进行了增强,使Feign支持了Spring M

 相关资料
  • 我想在一些计算机之间建立点对点连接,这样用户就可以在没有外部服务器的情况下聊天和交换文件。我最初的想法如下: 我在服务器上制作了一个中央服务器插座,所有应用程序都可以连接到该插座。此ServerSocket跟踪已连接的套接字(客户端),并将新连接的客户端的IP和端口提供给所有其他客户端。每个客户端都会创建一个新的ServerSocket,所有客户端都可以连接到它。 换句话说:每个客户端都有一个Se

  • URI 方法 URI() string 返回当前客户端使用的服务器地址。 SetURI 方法 SetURI(uri string) 设置当前客户端使用的服务器地址。如果你想要设置多个服务器地址,请使用 SetURIList 方法代替该方法。 URIList 方法 URIList() []string 返回当前客户端可使用的服务器地址列表。 SetURIList 方法 SetURIList(uriL

  • 客户端事件通过 SetEvent 方法进行设置。 客户端事件有两个,它们分别定义为: type onErrorEvent interface { OnError(name string, err error) }   type onFailswitchEvent interface { OnFailswitch(Client) } 因为 go 语言不需要显式实现接口的特点,所以这两

  • 创建客户端有两种方式,一种是直接使用特化的构造器函数,另一种是使用工厂构造器函数。 第一种方式返回的是具体的客户端结构体指针对象,第二种方式返回的是客户端接口对象。 使用特化的构造器函数创建客户端 特化的构造器函数有下面几个: func NewHTTPClient(uri ...string) (client *HTTPClient) func NewTCPClient(uri ...string

  • 客户端下载地址: windows 32位安装包 windows 64位安裝包 mac 安装包 Android App iOS App

  • 问题 你想使用网络上提供的服务。 解决方案 创建一个基本的 TCP 客户机。 在 Node.js 中 net = require 'net' domain = 'localhost' port = 9001 connection = net.createConnection port, domain connection.on 'connect', () -> console.log

  • 客户端调用服务端 服务端的proto文件copy到客户端 获取grpc客户端 //sample 为服务名称 var client = await provider.FindGrpcClient<RpcTest.RpcTestClient>("sample"); 调用服务方法 var result = await client.SayHelloAsync(new HelloRequest() {

  • Disque 在源码中附带了命令行客户端程序 disque , 通过这个程序可以以交互的形式向 Disque 发送命令: $ ./disque 127.0.0.1:7711> PING PONG 另外你也可以使用以下编程语言的客户端来操作 Disque : Ruby 客户端 https://rubygems.org/gems/disque Java 客户端 https://github.com/x