当前位置:网站首页>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使用———安装、测试
- NLP knowledge - pytorch, back propagation, some small pieces of notes for predictive tasks
- Location analysis of recording an online deadlock
- Add a little surprise to life and be a prototype designer of creative life -- sharing with X contestants in the programming challenge
- Knowledge maps are used to recommend system problems (mvin, Ctrl, ckan, Kred, gaeat)
- Application and innovation of low code technology in logistics management
- After having a meal with trump, I wrote this article
- 微信公众号开发 入手
- 【AI4Code】《CoSQA: 20,000+ Web Queries for Code Search and Question Answering》 ACL 2021
- Zero shot image retrieval (zero sample cross modal retrieval)
猜你喜欢

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

'C:\xampp\php\ext\php_zip.dll' - %1 不是有效的 Win32 应用程序 解决

Go garbage collector Guide

RestTemplate与Ribbon简单使用

记录一次线上死锁的定位分析

Ups and downs of Apple's supply chain in the past decade: foreign head teachers and their Chinese students

Transformer variants (routing transformer, linformer, big bird)

Learning to Pre-train Graph Neural Networks(图预训练与微调差异)

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

Brpc source code analysis (V) -- detailed explanation of basic resource pool
随机推荐
对比学习的应用(LCGNN,VideoMoCo,GraphCL,XMC-GAN)
web编程(二)CGI相关
OSPF综合实验
Web programming (II) CGI related
基于TCP/IP在同一局域网下的数据传输
Innovation and breakthrough! AsiaInfo technology helped a province of China Mobile complete the independent and controllable transformation of its core accounting database
PHP curl post x-www-form-urlencoded
【AI4Code】《Unified Pre-training for Program Understanding and Generation》 NAACL 2021
【GCN-RS】Are Graph Augmentations Necessary? Simple Graph Contrastive Learning for RS (SIGIR‘22)
【6篇文章串讲ScalableGNN】围绕WWW 2022 best paper《PaSca》
I advise those students who have just joined the work: if you want to enter the big factory, you must master these concurrent programming knowledge! Complete learning route!! (recommended Collection)
【AI4Code】《GraphCodeBERT: Pre-Training Code Representations With DataFlow》 ICLR 2021
[multimodal] hit: hierarchical transformer with momentum contract for video text retrieval iccv 2021
Power Bi -- these skills make the report more "compelling"“
winddows 计划任务执行bat 执行PHP文件 失败的解决办法
【多模态】《HiT: Hierarchical Transformer with Momentum Contrast for Video-Text Retrieval》ICCV 2021
Learning to pre train graph neural networks
Go 垃圾回收器指南
【AI4Code】《Pythia: AI-assisted Code Completion System》(KDD 2019)
Location analysis of recording an online deadlock