当前位置:网站首页>Feign use
Feign use
2022-07-25 12:14:00 【dengjili】
Feign Introduce
Feign It belongs to one of interface calls ,
| name | explain |
|---|---|
| Httpclient | HttpClient yes Apache Jakarta Common Sub projects under , To provide efficient 、 Abreast of the times 、 Feature rich support Http Client programming toolkit for protocol , And it supports HTTP The latest version of the agreement and recommendations .HttpClient Compared with tradition JDK Self contained URLConnection, Improved ease of use and flexibility , Make the client send HTTP It's easier to ask , Improved development efficiency . |
| Okhttp | An open source project to handle network requests , It's the most popular lightweight framework in Android , from Square The company contributed , Used in substitution HttpUrlConnection and Apache HttpClient.OkHttp Have a simple API、 Efficient performance , And support a variety of protocols (HTTP/2 and SPDY). |
| HttpURLConnection | HttpURLConnection yes Java Standard class , It is inherited from URLConnection, Can be used to send GET request 、POST request .HttpURLConnection It's complicated to use , Unlike HttpClient That's easy to use . |
| RestTemplate | RestTemplate yes Spring Provided for access Rest Client of service ,RestTemplate Provides a variety of convenient remote access HTTP Method of service , Can greatly improve the writing efficiency of the client . |
| Feign | Feign It's a declarative one REST client , It can make REST It's easier to call .Feign For HTTP Requested template , By writing simple interfaces and inserting annotations , You can define HTTP Requested parameters 、 Format 、 Address and other information . and Feign It'll be a complete agent HTTP request , We only need to call it like a method to complete the service request and related processing .Spring Cloud Yes Feign It was packaged , To support SpringMVC Standard notes and HttpMessageConverters.Feign It can be done with Eureka and Ribbon Combined to support load balancing . |
Get ready
start-up Eureka service , And register two applications as test cluster machines , As shown in the figure ; Test interface /hello
Feign Project use
To configure pom.xml rely on
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
encapsulation Feign Interface ,eureka-provider-app To register to Eureka Service name in
@FeignClient(value = "eureka-provider-app")
public interface TestClient {
@GetMapping("/hello")
String hello();
}
To configure client scanning
@SpringBootApplication
@EnableFeignClients(basePackageClasses = {
TestClient.class})
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
The configuration file application.properties add to Eureka Registration configuration
eureka.client.serviceUrl.defaultZone=http://192.168.1.55:8761/eureka/
Add test class
@RestController
public class TestController {
@Autowired
private TestClient client;
@GetMapping("/test")
public String test() {
String result = client.hello();
return result;
}
}
test , Test success

边栏推荐
- selenium使用———安装、测试
- R语言使用wilcox.test函数执行wilcox符号秩检验获取总体中位数(median)的置信区间(默认输出结果包括95%置信水平的置信区间)
- Zero shot image retrieval (zero sample cross modal retrieval)
- 记录一次线上死锁的定位分析
- Intelligent information retrieval(智能信息检索综述)
- Go garbage collector Guide
- [high concurrency] I summarized the best learning route of concurrent programming with 10 diagrams!! (recommended Collection)
- Eureka注册中心开启密码认证-记录
- 协程
- Scott+scott law firm plans to file a class action against Yuga labs, or will confirm whether NFT is a securities product
猜你喜欢

【Debias】Model-Agnostic Counterfactual Reasoning for Eliminating Popularity Bias in RS(KDD‘21)

【GCN-RS】Are Graph Augmentations Necessary? Simple Graph Contrastive Learning for RS (SIGIR‘22)

Multi-Label Image Classification(多标签图像分类)

Transformer variants (spark transformer, longformer, switch transformer)

Transformer变体(Routing Transformer,Linformer,Big Bird)

Innovation and breakthrough! AsiaInfo technology helped a province of China Mobile complete the independent and controllable transformation of its core accounting database

【CTR】《Towards Universal Sequence Representation Learning for Recommender Systems》 (KDD‘22)

Go garbage collector Guide

Eureka使用记录

dirReader. Readentries compatibility issues. Exception error domexception
随机推荐
JS interview question: handwriting throttle function
selenium使用———xpath和模拟输入和模拟点击协作
银行理财子公司蓄力布局A股;现金管理类理财产品整改加速
客户端开放下载, 欢迎尝鲜
Brpc source code analysis (V) -- detailed explanation of basic resource pool
Solutions to the failure of winddowns planning task execution bat to execute PHP files
Video caption (cross modal video summary / subtitle generation)
[untitled]
【6篇文章串讲ScalableGNN】围绕WWW 2022 best paper《PaSca》
【黑马早报】运营23年,易趣网宣布关停;蔚来对大众CEO抛出橄榄枝;华为天才少年曾放弃360万年薪;尹烨回应饶毅炮轰其伪科学...
那些离开网易的年轻人
Meta learning (meta learning and small sample learning)
[high concurrency] Why is the simpledateformat class thread safe? (six solutions are attached, which are recommended for collection)
Atomic 原子类
keepalived实现mysql的高可用
R语言组间均值是否相同的成对比较:使用pairwise.t.test函数执行多个分组数据均值的两两成对假设检验
Median (二分答案 + 二分查找)
【GCN-RS】MCL: Mixed-Centric Loss for Collaborative Filtering (WWW‘22)
【多模态】《TransRec: Learning Transferable Recommendation from Mixture-of-Modality Feedback》 Arxiv‘22
【AI4Code】《Contrastive Code Representation Learning》 (EMNLP 2021)