当前位置:网站首页>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

边栏推荐
- dirReader.readEntries 兼容性问题 。异常错误DOMException
- Scott+Scott律所计划对Yuga Labs提起集体诉讼,或将确认NFT是否属于证券产品
- 知识图谱用于推荐系统问题(MVIN,KERL,CKAN,KRED,GAEAT)
- Transformer variants (routing transformer, linformer, big bird)
- Video Caption(跨模态视频摘要/字幕生成)
- 【GCN-RS】Are Graph Augmentations Necessary? Simple Graph Contrastive Learning for RS (SIGIR‘22)
- Heterogeneous graph neural network for recommendation system problems (ackrec, hfgn)
- PHP 上传ftp路径文件到外网服务器上 curl base64图片
- 【Debias】Model-Agnostic Counterfactual Reasoning for Eliminating Popularity Bias in RS(KDD‘21)
- From cloud native to intelligent, in-depth interpretation of the industry's first "best practice map of live video technology"
猜你喜欢

和特朗普吃了顿饭后写下了这篇文章

【多模态】《TransRec: Learning Transferable Recommendation from Mixture-of-Modality Feedback》 Arxiv‘22

【AI4Code最终章】AlphaCode:《Competition-Level Code Generation with AlphaCode》(DeepMind)

利用wireshark对TCP抓包分析

Power Bi -- these skills make the report more "compelling"“

Meta-learning(元学习与少样本学习)

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

【GCN-RS】MCL: Mixed-Centric Loss for Collaborative Filtering (WWW‘22)

【AI4Code】《IntelliCode Compose: Code Generation using Transformer》 ESEC/FSE 2020

Application of comparative learning (lcgnn, videomoco, graphcl, XMC GaN)
随机推荐
PHP curl post x-www-form-urlencoded
PHP curl post x-www-form-urlencoded
Power Bi -- these skills make the report more "compelling"“
协程
【GCN-RS】Region or Global? A Principle for Negative Sampling in Graph-based Recommendation (TKDE‘22)
dirReader.readEntries 兼容性问题 。异常错误DOMException
[RS sampling] a gain tuning dynamic negative sampler for recommendation (WWW 2022)
马斯克的“灵魂永生”:一半炒作,一半忽悠
【GCN-RS】MCL: Mixed-Centric Loss for Collaborative Filtering (WWW‘22)
Innovation and breakthrough! AsiaInfo technology helped a province of China Mobile complete the independent and controllable transformation of its core accounting database
【GCN-RS】Towards Representation Alignment and Uniformity in Collaborative Filtering (KDD‘22)
[multimodal] hit: hierarchical transformer with momentum contract for video text retrieval iccv 2021
Brpc source code analysis (II) -- the processing process of brpc receiving requests
Hardware connection server TCP communication protocol gateway
PHP curl post length required error setting header header
剑指 Offer 22. 链表中倒数第k个节点
Data transmission under the same LAN based on tcp/ip
【AI4Code】《GraphCodeBERT: Pre-Training Code Representations With DataFlow》 ICLR 2021
R语言ggplot2可视化:可视化散点图并为散点图中的部分数据点添加文本标签、使用ggrepel包的geom_text_repel函数避免数据点之间的标签互相重叠(为数据点标签添加线段、指定线段的角度
30 sets of Chinese style ppt/ creative ppt templates